backbone.js - Backbone submit stucked -


here html code:

<div id="overlay">     <form action="/login" id="login_form">         <input type="text" placeholder="login" id="login_form-login">         <input type="text" placeholder="password" id="login_form-password">         <input type="submit" value="log in">     </form> </div> 

and here backbone code:

loginform = backbone.view.extend({     el: $("#overlay"),     events: {         "submit #login_form" : "login",     },     login: function(e) {         e.preventdefault();         console.log("hello backbone");     } });  var login_view = new loginform(); 

login function never called. know backbone models , templates, there way bind event existing html form?

well, found solution.

mu short right - #overlay did not exist yet when code executed.

here fix:

$(document).ready(function(){     var login_view = new loginform();     login_view.show(); }); 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -