Jquery UI checkbox as button change text value -
i using jquery ui , trying change text on checkboxes (they buttons). reason unable text change on each change event using toggle method. here html coming out in ie 8
<div data-hands-jqui-type='buttonset' data-hands-jqui-props='{"buttonwidth":0,"disabled":false,"handsoncreate":null}' class='editor-field ui-widget'> <label for="isclosedsunday">open</label> <input data-hands-jqui-props="{}" data-hands-jqui-type="checkfield" data-hands-onchange="vendor.isclosedselected" data-val="true" data-val-required="the open field required." id="isclosedsunday" name="isclosedsunday" type="checkbox" value="true" /> <input name="isclosedsunday" type="hidden" value="false" /> </div>
to me looks label need change, couldn't figure out how it.
now found on thread use this:
$("#isclosedsunday").button().toggle(function () { $(this).button('option', 'label', 'open'); }, function () { $(this).button('option', 'label', 'closed'); });
with set up, change 'open' 'closed' when checked, doesn't go 'open' on uncheck.
any ideas?
try this:-
$("#isclosedsunday").button().click(function () { var text = $(this).is(':checked')? "closed": "open" $(this).button('option', 'label', text); });
you can use change
event too.
$("#isclosedsunday").button().change(function () { var text = $(this).is(':checked')? "closed": "open" $(this).button('option', 'label', text); });
in code using toggle()
not event on button(rather checkbox). forces toggle state button when call .toggle()
initially. wont triggered when check or change checkbox. should use change
or click
event that. think toggle doesn't support 2 call backs.
Comments
Post a Comment