I am using knockout as main framework in my application and it has to support tablets and mobile devices. As the framework is built on binding handlers I wonder how can custom binding to actions (like swipe and other device specific ones) be achieved, or maybe there is something like this done?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
There are no built in bindings for specific frameworks as knockout.js has no dependencies on any other framework. It should be a trivial task to convert your jQuery selector code to binding handlers referencing the link @niko provides above.
Create a
bindingHandler
. Here you go an example of a real project};
Using a swipe library: https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
Define the item's binding
Probably too late, but here is a library that adds touch binding to knockoutjs: https://github.com/yaroslavya/knockouch
I dont know if it still helps, but here is a pointer.
http://jsfiddle.net/snaptopixel/spByj/
now all you do in your html is
where doSomething is a function.