mirror of https://github.com/apache/archiva.git
better to use a select2 binding: add it
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1452604 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f945442570
commit
5800980416
|
@ -0,0 +1,29 @@
|
|||
(function(factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// AMD anonymous module
|
||||
define("knockout.select2",["jquery","knockout","utils","select2"], factory);
|
||||
} else {
|
||||
// No module loader (plain <script> tag) - put directly in global namespace
|
||||
factory(window.ko, jQuery);
|
||||
}
|
||||
})(function ($,ko,utils,select2) {
|
||||
|
||||
|
||||
ko.bindingHandlers.select2 = {
|
||||
init: function(element, valueAccessor) {
|
||||
$.log("select2 binding#init");
|
||||
$(element).select2(valueAccessor());
|
||||
|
||||
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
|
||||
$(element).select2('destroy');
|
||||
});
|
||||
},
|
||||
update: function(element) {
|
||||
$.log("select2 binding#update");
|
||||
$(element).trigger('change');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
})
|
Loading…
Reference in New Issue