backbone.js click event not firing

后端 未结 2 1894
鱼传尺愫
鱼传尺愫 2021-01-12 20:07

Going through a very basic tutorial on backbone.js views.

The expected behavior is to call the render function when #sayhello button is clicked. Render simply uses

相关标签:
2条回答
  • 2021-01-12 21:02

    It's because #sayhello is not part of your view. Try putting #sayhello inside #helloworld:

    <div id="helloworld">
        <button id="sayhello">Say Hello</button>
    </div>
    
    0 讨论(0)
  • 2021-01-12 21:09

    If you are dynamically rendering the page using the templates, then in the render function consider calling view.setElement(...);

    this.setElement($('#login-container'));

    0 讨论(0)
提交回复
热议问题