我有很多Backbone.js操作,从链接开始
- <a href="#makeCookies">Make Cookies</a>
和Backbone.View事件哈希像
- 'click [href=#makeCookies]': 'makeCookies'
和一个事件处理函数
- makeCookies: function (event) {
- event.preventDefault();
- //code to make cookies
- //I have no intention of ever using #makeCookies in the URL,//it's just there so I can wire up the event handler properly
- }
有没有一个干净的方法来避免这个模板event.preventDefault().我想到只要使用< button>代码而不是< a>标签,但似乎不合适.