ErichBSchulz ErichBSchulz - 3 months ago 8
jQuery Question

can you use backbone listenTo with jquery objects?

Such as those returned by

$("#mystuff")
etc?

For example, can:

$('#div').on(event, callback)


be re-written as:

view.listenTo($('#div'), event, callback)

Answer

No it turns out you can't.

You've got jQuery for that.

According to tgriesser

Sorry, listenTo only applies to objects that have the Backbone.Events mixed in, so it would work on a Backbone.View, Backbone.Collection, or Backbone.Model, but not on a jQuery object.

dang.

Some folk also suggest creating a backbone view rather than using jquery events.