Guest User

Untitled

a guest
Jan 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. var resultsListView = new ResultsListView({model: comparablesList});
  2.  
  3. ResultsListView = Backbone.View.extend({
  4. tagName:'div',
  5. id:'resultView',
  6. template:_.template("<div class='resultsListItemView'></div>"),
  7.  
  8. initialize:function () {
  9. $( this.el ).html('<p class="loadingText">Getting comparables...<p>');
  10. this.model.bind("change", this.render, this);
  11. this.model.bind("reset", this.loading, this);
  12. },
  13.  
  14. render:function (eventName) {
  15. $( this.el ).html( this.template() );
  16.  
  17. _.each(this.model.models, function (comparable) {
  18. this.$('.resultsListItemView').append(new ResultsListItemView({model:comparable}).el);
  19. }, this);
  20.  
  21. $('#info').html($(this.el));
  22.  
  23. return this;
  24. }
  25. });
  26.  
  27. ResultsListItemView = Backbone.View.extend({
  28. initialize: function(){
  29. this.render();
  30. },
  31.  
  32. template:_.template("<div class='hovr_item'>
  33. <div class='hovr'>
  34. <button class='test123'>test</button>
  35. </div>
  36. </div> "),
  37.  
  38. render: function(){
  39. var resultsListItemView = this;
  40. $(this.el).html(this.template(this.model.toJSON()));
  41.  
  42. $(this.el).find('.test123').click(function() {
  43. console.log('click'); // this does not work after clicking
  44. });
  45. return this;
  46. }
  47. });
  48.  
  49. $(this.el).find('.test123').each(function(index) {
  50. console.log('found');
  51. });
  52.  
  53. events: "click .test123": "affiliateClick"
Add Comment
Please, Sign In to add comment