Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var resultsListView = new ResultsListView({model: comparablesList});
- ResultsListView = Backbone.View.extend({
- tagName:'div',
- id:'resultView',
- template:_.template("<div class='resultsListItemView'></div>"),
- initialize:function () {
- $( this.el ).html('<p class="loadingText">Getting comparables...<p>');
- this.model.bind("change", this.render, this);
- this.model.bind("reset", this.loading, this);
- },
- render:function (eventName) {
- $( this.el ).html( this.template() );
- _.each(this.model.models, function (comparable) {
- this.$('.resultsListItemView').append(new ResultsListItemView({model:comparable}).el);
- }, this);
- $('#info').html($(this.el));
- return this;
- }
- });
- ResultsListItemView = Backbone.View.extend({
- initialize: function(){
- this.render();
- },
- template:_.template("<div class='hovr_item'>
- <div class='hovr'>
- <button class='test123'>test</button>
- </div>
- </div> "),
- render: function(){
- var resultsListItemView = this;
- $(this.el).html(this.template(this.model.toJSON()));
- $(this.el).find('.test123').click(function() {
- console.log('click'); // this does not work after clicking
- });
- return this;
- }
- });
- $(this.el).find('.test123').each(function(index) {
- console.log('found');
- });
- events: "click .test123": "affiliateClick"
Add Comment
Please, Sign In to add comment