开发者

How to use backbone js with some legacy plugins?

开发者 https://www.devze.com 2023-04-10 02:57 出处:网络
I\'ve working on a project and I\'m using some jquery plugins, right now I\'m trying to update my code to use backboje js but it\'s not clear how to put together those old plugins with backbone js.

I've working on a project and I'm using some jquery plugins, right now I'm trying to update my code to use backboje js but it's not clear how to put together those old plugins with backbone js.

the most important plugin I w开发者_Go百科ant to use is jcvl (http://code.google.com/p/jcvl/) but I'm trying to put this question general to get more ideas about how to integrate any pluggin with backbone.


Backbone only creates one global variable, Backbone, so there shouldn't be any conflicts with any jQuery plugins. Backbone also depends on Underscore.js, which also only creates one global variable, _, so it also shouldn't cause any conflicts. And if there is a conflict, both Backbone and Underscore.js offer you a noConflict() option.

I've been using Backbone with jQuery plugins for a while and haven't encountered any problems. You would use the plugin in the same way as before you introduced Backbone. For example:

var MyView = Backbone.View.extend({

  render: function(){
    $(this.el).html('<div class="foo"></div>');
    this.$('.foo').somejQueryPlugin();
  }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号