Saturday, 15 June 2013

javascript - Raise click event on an element from another template -



javascript - Raise click event on an element from another template -

i made view saving , showing models. has events this,

events: -> "click li": "addentry" "click .remove": "destroyentry" addentry: (e) -> movie_title = $(e.target).text() @collection.create title: movie_title appendentry: (entry) -> view = new movieseat.views.entry(model: entry) $('#entries').append(view.render().el) destroyentry: (e) -> thisid = @$(e.currenttarget).closest('div').data('id') @collection.get(thisid).destroy()

now if set li element in template , click on addentry event gets triggerd , saves model rails database. destroyentry event works remove models. , appendentry function gets triggered when model gets added collection.

but i'm using different view show collection of movies in list. want connect click li event li on different template. possible? if so, how?

in other view, can utilize same source of data. in case collection of movies. since it's backbone, , views representation of info models, utilize info render or trigger changes in views.

in other view, watch changes on collection beingness manipulated. no need delegate events when care info beingness changed.

otherview = backbone.view.extend initialize: (params) -> # model, i'm not sure how have configured @listento params.movieseats, "change", @updatemovies updatemovies: -> # manage view here

javascript jquery ruby-on-rails backbone.js

No comments:

Post a Comment