Forked from codescribler/wysihtml5 ko binding handler
Created
November 19, 2012 12:38
-
-
Save rix0rrr/4110437 to your computer and use it in GitHub Desktop.
A binding handler for binding knockout observables to a wysihtml5 editor
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()); | |
} | |
} | |
}; |
Nevermind I figured it out. Thank you for this handler :)
@rix0rrr @ajaxmonk I am also trying to figure out how to bind my content to this handler. Can you post your solution?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Once I have this code pasted in, how do I type out the data-bind for it?