Changing addLineItem.js to change the value of a select box rather than including the generated form helper stuff..

This commit is contained in:
Karl Cordes 2010-02-22 10:20:24 +11:00
parent 70a1c14a48
commit ec67ed76e2
5 changed files with 22 additions and 4 deletions

View file

@ -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')));
}

View file

@ -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'));
?>

View file

@ -0,0 +1,3 @@
<?
print_r($productOptions);
?>

View file

@ -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>

View file

@ -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);
});
}