Created
July 29, 2012 22:26
-
-
Save eknuth/3202211 to your computer and use it in GitHub Desktop.
Google FastButtons as knockout.js custom binding
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 characters
ko.applyBindings({ | |
fastClickResult: ko.observable("Waiting..."), | |
clickResult: ko.observable("Waiting..."), | |
handleClick: function(self, event) { | |
self.clickResult("Clicked!"); | |
}, | |
handleFastClick: function(self, event) { | |
self.fastClickResult("Fast Clicked!"); | |
} | |
}); |
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 characters
ko.bindingHandlers.fastClick = { | |
init: function(element, valueAccessor, allBindingsAccessor, viewModel) { | |
new FastButton(element, function() { | |
valueAccessor()(viewModel, event); | |
}); | |
} | |
}; |
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 characters
<button class="btn" data-bind="click: handleClick">click</button> | |
<button class="btn" data-bind="fastClick: handleFastClick">fastClick</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment