Javascript
knockoutjs
Create Chrome Plugin with Knockoutjs
Muhammad Raheel
August 26th, 2014 · 1 min read
Greetings. I am going to present a simple way to create a chrome plugin using knockoutjs. As you know knockout needs two things. A view and a viewmodel. View is simply written in html file while viewmodel is a javascript object/function which is then bound to view with knockout. For loading view you can see this post.
And for loading viewmodel here is the code.
var pluginViewModel = function(){
// code here
}
// for component
ko.components.register('plugin',{
template : pluginTemplate,
viewModel : pluginViewModel
});
$('body').append('<div data-bind="component:plugin"></div>');
ko.applyBindings()
// For simple viewmodel
$('body').append(pluginTemplate);
ko.applyBindings(new pluginViewModel())
Hope it is very easy and useful. Do reply if you need to ask anything.
Found this useful?
Support the work that goes into these posts.
Comments
Comment created and will be displayed once approved.