javascript - knockout autogrow binding removes change event binding -
i have custom binding jquery autogrow plugin can seen here autosize knockout custom binding autosize on load
the code reference:
ko.bindinghandlers.autogrow = { init: function (element, valueaccessor, allbindingsaccessor) { ko.applybindingstonode(element, { value: valueaccessor() }); ko.utils.domnodedisposal.adddisposecallback(element, function () { //$(element).data('autosize').remove(); }); $(element).autosize({ append: "\n" }); $(element).focus(function () { $(element).trigger('autosize'); }); } };
i using follows:
<textarea id="autogrow" class="text-nm span2" data-bind="autogrow: areaprocessname, attr: { id: 'areaprocessname' + id }, event: { change: viewmodel.vmareaprocess.setarearevision($data) }"></textarea>
the attr binding still working event binding on change has stopped working.
any ideas?
jsfiddle.net/sujesharukil/3p9bj/17 seems working fine. did remove ($data) change event. reason pointed out in first comment when set
data-bind="event: {'someevent': func()}
what happening is, handler someevent being set return of func() call. since function viewmodel.vmareaprocess.setarearevision not returning handler function, not callback when fired because func() executed immediately.
when set this
data-bind="event: {'someevent': func}
you binding 'someevent' func handler. func executed when event fired. hope clears it?
Comments
Post a Comment