I'm trying to incorporate Remy's select-chain plug-in into my code, and I'm having troubles. I hope someone can take a minute or two to help me.
My situation seemed simple, only 2 levels, Products and Programs under each Product. I have the back-end working, so it returns the JSON list of Programs when a Product ID is passed. However, the plug-in keeps failing in the .ajax() function, tripping the error(). It reports a "parsererror", so I know I've messed up something.
One wrinkle, I have multiples of the Product/Program pairs on my page, identified as "prod_x"/"prog_x", so I need to dynamically call them. Here is my code:
- var pgmid;
$('select[id^="prod_"]').change(function(){
var prodid = $(this).attr('ID');
pgmid = "prog" + prodid.substring(prodid.indexOf('_'));
//alert("Program ID = " + pgmid);
}).selectChain({
// target: $('#' + pgmid),
target: $('#prog_0'),
url: "edit_ajax.php?id=" + $(this).val(),
data: { ajax: true } // , id: $(this).val()
});
I'm not sure how to get the linked Program element correctly. Calling the "change()" first to assign the pgmid should work, but it isn't. But even when I hard-code the "prog_0", it still doesn't work.
Another note, when I display the error message from the select-chain plug-in, I get this:
"jQuery15076..._13009... was not called". The first part of the jQuery string matches the jQuery field from my jQuery execution, but there is an underscore, then a bunch of other numbers after it. That sounds off to me.
Any help would be much appreciated.
Thanks.