javascript - How to: Swap options with jQuery while using jQuery UI -
i've been trying find way swap option values between them while using jquery ui. made simple fiddle swap options works when i'm not using jquery ui.
working fiddle without jquery ui loaded on options: http://jsfiddle.net/mbmrp/
working fiddle with jquery ui loaded on options: http://jsfiddle.net/fuuyq/
thanks alot
you'll need distroy selectmenu , rebind check out fiddle
$('select').selectmenu(); $('.swap a').click(function() { var opt1 = $(this).parent().prev('.forms').find('option'); var opt2 = $(this).parent().next('.forms').find('option'); // remove them dom. opt1.detach(); opt2.detach(); // , put them back. $(this).parent().prev('.forms').find('select').append(opt2); $(this).parent().next('.forms').find('select').append(opt1); $('select').selectmenu('destroy').selectmenu(); });
Comments
Post a Comment