Reputation: 2777
I have a div:
<div class = "desc"></div>
this div is in a template that a backbone view loads.
Here's the Backbone View: DetailsView = Backbone.View.extend({ events: {.....});
I want when the template loads, to call the following jquery function:
How can I do that?
$('#desc').expander({
slicePoint: 50,
expandText: 'Click Here to Read More',
userCollapseText: 'Hide Text'
});
It is from the expander jquery plugin.
Upvotes: 2
Views: 8788
Reputation: 221
have you included your JS files in the header ? or in footer section. This is one common issue happens during implementation .
Upvotes: 0
Reputation: 309
It is possible to do something like that:
initialize: function () {
this.once('renderEvent', function () {
// that will be executed just once after the view has been rendered
});
},
render: function () {
// display html
// ...
this.trigger('renderEvent');
}
Upvotes: 1
Reputation: 11895
you could do something like:
... Rest of View...
render: function() {
// do your normal render stuff
this.afterRender();
},
afterRender: function() {
// do the stuff you want to do after the template is rendered
}
Upvotes: 6