拆卸backbone.router和意见的jQuery /仄依赖 [英] Removing the jquery/zepto dependency on backbone.router and views

查看:176
本文介绍了拆卸backbone.router和意见的jQuery /仄依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有骨干分叉/维护版本,完全省去了jQuery的或仄同时使用路由器和看法?

Is there a forked/maintained version of backbone that completely eliminates the need for jquery or zepto to use both the router and views?

我不介意使用的骨干,但没有办法在赫克我会逼我的网页上一个jQuery的依赖只是使用它。

I wouldn't mind using backbone but there's no way in heck I'd force a jquery dependency on my page just to use it.

如果一个解决方案,不存在可以有人张贴什么需要依据被精确改变?

If a solution doesn't exist can someone post a gist of what needs to be changed exactly?

推荐答案

如果你想主干处理DOM操作,DOM事件和AJAX请求,那么你就需要另外一个库来做到这一点。它并不必须是jQuery的或的Zepto - 主干还支持安德,并且理论上可以使用,可以做的DOM选择和支持的jQuery式方法的子集的任何库。快速浏览一下通过注明出处code 表明,你需要下面的方法:

If you want Backbone to handle DOM manipulation, DOM events, and AJAX requests, then you'll need another library to do this. It doesn't have to be jQuery or Zepto - Backbone also supports Ender, and you could theoretically use any library that can do DOM selection and supports a subset of jQuery-style methods. A quick look through the annotated source code shows that you need the following methods:


  • $(选择)

  • $。阿贾克斯()

  • $(选择).find()

  • $(选择).bind()

  • $(选择).unbind()

  • $(选择).delegate()

  • $(选择)一个.remove()

  • $(选择).attr()

  • $(选择)的.html()

  • $(selector)
  • $.ajax()
  • $(selector).find()
  • $(selector).bind()
  • $(selector).unbind()
  • $(selector).delegate()
  • $(selector).remove()
  • $(selector).attr()
  • $(selector).html()

如果你不想骨干来处理这个东西,你可以很容易地pretty通过覆盖使用它们的方法去除的要求 - 例如,你可以用 .attr()的.html()通过设置 Backbone.View免除.prototype.make =功能(){} 。或者只是不使用 Backbone.View - 这消除了一切,但 $需要AJAX()(除非你使用 pushState的,在这种情况下,你需要事件绑定太)。

If you don't want Backbone to deal with this stuff, you can pretty easily remove the requirements by overwriting the methods that use them - e.g. you can dispense with .attr() and .html() by setting Backbone.View.prototype.make = function() {}. Or just don't use Backbone.View - that removes the need for everything but $.ajax() (unless you're using pushState, in which case you need event binding too).

这篇关于拆卸backbone.router和意见的jQuery /仄依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆