How do I use jQuery sortable?

What is the best way to use jquery and backbone in order to get good cooperation between them!

  • I would like to ask you about use backbone and jquery in order to get right cooperation between them. Natively backbone has event system end underscode as hard dependency. Underscore looks like even well designed solution with quite big bunch of functions. Event system with underscore gives really powerfull indepent system. Where is jquery placed in this cooperation out of events and templates? Might be underscore and native event system of backbone aren't so powerful as it looks like?

  • Answer:

    If the question is how to get Backbone to work with jQuery, then we're done! Backbone supports jQuery out of the box. However, if you are asking about binding to jQuery events, instead of using Backbone's delegateEvents (http://documentcloud.github.com/backbone/#View-delegateEvents) functionality, then continue reading. If you follow the link I provided, Backbone does use jQuery for delegating events via a Backbone View's events hash. The hash allows you to bind to jQuery events that are scoped to the context of the view. For example, if you want to trigger a method whenever someone double clicks a button, the events hash may look like: events = { 'dblclick button': 'someMethod' }; This will call the 'someMethod' method in the view. This is the best way to bind to jQuery events in a Backbone view. If you really want to use jQuery's bind method, you can do something like this in the view: this.$('button').bind('dblclick', _.bind(this.someMethod, this));

Darren Fung at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.