javascript - jQuery dialog opens with same selected option -
i have 2 orders , b. when click on a, opens dialog select alternative defaults on blank has yes or no. when click on b ,it opens dialog select alternative well; however, instead of defaulting on blank carries on whatever selected a.
i need b open fresh dialog first time clicked. need remember user selected lastly time.
i have tried $("#input select option:selected").val("y")
, , set value; not on ui itself. causes issues when want hide elements based on whether y or n selected.
you want saving selected alternative somewhere, , setting value of <select>
saved value when dialog opened.
something below should started.
var orderdata = {}; // -- object save info var activeel; // -- maintain track of button we've clicked $('#btnorder1,#btnorder2').click(function(){ // -- open dialog $('#dialog').dialog({ title:'order options', modal: true }); // -- set lastly clicked button id of 1 clicked... activeel = this.id; // -- set select's alternative value we've stored. // -- unless don't have value, in case we'll utilize "empty". $('#selorderoption').val(orderdata[activeel] || ''); }); // -- set save click handler $('#btnsave').click(function(){ // -- save selected value, keyed active button's id orderdata[activeel] = $('#selorderoption').val(); $('#dialog').dialog("close"); });
http://jsfiddle.net/davesalomon/7lds66td/
javascript jquery jquery-ui jquery-dialog
No comments:
Post a Comment