Last active
October 6, 2017 14:11
-
-
Save tomazy/9800573 to your computer and use it in GitHub Desktop.
Revisions
-
tomazy revised this gist
Mar 27, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ ko.bindingHandlers.chosen = { else $element.chosen(); ['options', 'selectedOptions', 'value'].forEach(function(propName){ if (allBindings.has(propName)){ var prop = allBindings.get(propName); if (ko.isObservable(prop)){ -
tomazy created this gist
Mar 27, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ ko.bindingHandlers.chosen = { init: function(element, valueAccessor, allBindings, viewModel, bindingContext){ var $element = $(element); var options = ko.unwrap(valueAccessor()); if (typeof options === 'object') $element.chosen(options); else $element.chosen(); ['options', 'selectedOptions'].forEach(function(propName){ if (allBindings.has(propName)){ var prop = allBindings.get(propName); if (ko.isObservable(prop)){ prop.subscribe(function(){ $element.trigger('chosen:updated'); }); } } }); } }