-
-
Save agea/5262432 to your computer and use it in GitHub Desktop.
This file contains 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 characters
/** | |
* Correct version of a wysihtml5 binding for KnockoutJS that is safe for multiple inclusion on a single page | |
*/ | |
ko.bindingHandlers.wysihtml5 = { | |
init: function (element, valueAccessor, allBindingsAccessor, viewModel) { | |
var control = $(element).wysihtml5({ | |
"events": { | |
"change" : function() { | |
var observable = valueAccessor(); | |
observable(control.getValue()); | |
} | |
} | |
}).data("wysihtml5").editor; | |
}, | |
update: function (element, valueAccessor, allBindingsAccessor, viewModel) { | |
var content = valueAccessor(); | |
if (content != undefined) { | |
var control = $(element).data("wysihtml5").editor; | |
control.setValue(content()); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment