Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 917
ErichBSchulz Avatar asked Apr 23 '13 08:04

ErichBSchulz


1 Answers

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.

like image 123
ErichBSchulz Avatar answered Sep 30 '22 18:09

ErichBSchulz