Dynamic select menus not working with added fields
listed in answer
ANSWER:
@Jeff, you my want something like this:
var $products_backup = $('#products_backup');
$('form').on('click', '.category', function()
var $category = $(this);
if (!$category.is(":checked"))
return;
var escaped_category = $category.val().replace(/([ #;&,.+*~':"!^$[]()=>|/@])/g, '\$1');
var $options = $products_backup.find("optgroup[label='" + escaped_category + "']").find("option");
//$('#products').empty().append('').append($options.clone()).val("");
$category.closest('fieldset').find('.products').empty().append('').append($options.clone()).val("");
});
See :
As you will see I guessed that the .category elements might be radio buttons. If they are not, then the code will need to be adjusted to a greater or lesser extent.
by Beetroot-Beetroot from http://stackoverflow.com/questions/10565773

New Comments