Changing addLineItem.js to change the value of a select box rather than including the generated form helper stuff..
This commit is contained in:
parent
70a1c14a48
commit
ec67ed76e2
|
|
@ -116,8 +116,8 @@ class ProductsController extends AppController {
|
|||
}
|
||||
|
||||
else {
|
||||
|
||||
|
||||
$this->set('productOptions', $this->Product->findById($this->data['LineItem']['product_id']));
|
||||
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$id), 'order'=>'ProductOptionsCategory.location ASC')));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<?
|
||||
echo $form->input('LineItem.product_id', array('options' => $products, 'div' => false));
|
||||
echo $form->input('LineItem.product_id', array('options' => $products, 'div' => false, 'empty'=>'Select the Product'));
|
||||
?>
|
||||
3
views/products/get_product_options.ctp
Normal file
3
views/products/get_product_options.ctp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?
|
||||
print_r($productOptions);
|
||||
?>
|
||||
|
|
@ -218,7 +218,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
|||
|
||||
<?php
|
||||
|
||||
echo $form->input('principle_id', array('options'=>$principles));
|
||||
echo $form->input('principle_id', array('options'=>$principles, 'empty' =>'Select the Principle for this Product'));
|
||||
?>
|
||||
|
||||
<div id="productBox" class="input select"></div>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ $(function() {
|
|||
|
||||
|
||||
$("#LineItemPrincipleId").change(getPrincipleProducts);
|
||||
|
||||
$("#LineItemProductId").change(getProductOptions); //broken because this ID doesnt exist yet.
|
||||
//Ways to fix this. Quick and nasty to have a blank div or span that we destroy.. or something.
|
||||
// Better, maybe have the element already existing, and just update and show it with JSON data.
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -58,4 +62,15 @@ function getPrincipleProducts() {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajax Request to get the Product Options (if any) for the Product selected
|
||||
*/
|
||||
|
||||
function getProductOptions() {
|
||||
alert('FARK');
|
||||
$.post("/products/getProductOptions", $("#LineItemAddForm").serialize(), function(optionData) {
|
||||
alert(optionData);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue