0

View:

 Member.Views.Popover = Backbone.View.extend({
    template: "member/default",
    tagName: 'a',
    className: 'header-auth member',
    events: {
      'click a.member': 'toggle'
    },        
    initialize: function() {    
      //todo
    },
    toggle: function(){   
      console.log("toggle");
    }
  });

Output:

<a class="header-auth member">
    //content from template
</a>

First problem: first I defined just a template without tagName and className because this data was already set in the template. But this wrapped the template with a div. To avoid that I set tagName and className and removed this data from template because now it is set by backbone.

Second problem: now that I use tagName the click event does not work anymore.

Any ideas how to fix this?

4
  • 1
    Where are you calling render on the view? Commented Jul 4, 2013 at 6:51
  • You can change click a.member to merely click, since the element is your view. Commented Jul 4, 2013 at 6:52
  • @kalley this works^^ make this an answer Commented Jul 4, 2013 at 6:53
  • 1
    @Matt app.useLayout("main-layout").setViews({ ".aClass": new Member.Views.Popover({model : this.member }) }).render(); in main.js Commented Jul 4, 2013 at 6:54

1 Answer 1

2

You can should change click a.member to merely click, since the element is your view.

Sign up to request clarification or add additional context in comments.

2 Comments

You can, no, You should.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.