Does anyone know which event is fired after a view is rendered in backbone.js?
标签:
backbone.js
相关问题
- Backbone.js PushState routes .htaccess only workin
- Updating a LayoutView's Model
- Disable Backbone.js hashes entirely, but keep push
- Is there an easy way to distribute a Flask server
- React + Backbone, Target container is not a DOM el
相关文章
- Get all models in backbone collection where attrib
- How can I dynamically set a className for a Backbo
- Nesting Views within Views in backbone js
- Backbone-relational hasmany best practices
- JavaScript error: “is not a constructor”
- Marionette + i18n in templates
- Rendering reCAPTCHA v2.0 widget within Backbone vi
- Backbone.js PUT/DELETE problems with Codeigniter R
I ran into this post which seems interesting
Instead of adding the eventhandler manually to render on intialization you can also add the event to the 'events' section of your view. See http://backbonejs.org/#View-delegateEvents
e.g.
like this http://jsfiddle.net/8hQyB/
As far as I know - none is fired. Render function is empty in source code.
I would recommend just triggering it manually when necessary.
If you happen to be using Marionette, Marionette adds
show
andrender
events on views. See this StackOverflow question for an example.On a side note, Marionette adds a lot of other useful features that you might be interested in.
Or you can do the following, which is what Backbone code is supposed to look like (Observer pattern, aka pub/sub). This is the way to go:
Edit:
this.on('render', 'afterRender');
will not work - becauseBackbone.Events.on
accepts only functions. The.on('event', 'methodName');
magic is made possible byBackbone.View.delegateEvents
and as such is only available with DOM events.