jquery - Backbone.Syphon - always return empty object -
i using backbone.syphon
plugin in backbone.marionette app. when click on submit button form, getting empty object({}).. don't know reason that,
any 1 me find issue pelase?
here view.js
define([ 'jquery','underscore', 'backbone','marionette', 'text!./templates/loginview.html'], function($,_,backbone,marionette,template){ "use strict"; var loginview = backbone.marionette.itemview.extend({ classname:'col-xs-12 col-md-4 col-md-offset-4', template:_.template(template), events:{ "submit form" : "loginsubmit" }, loginsubmit:function(e){ e.preventdefault(); var data = backbone.syphon.serialize(e.target); console.log(data); //always return empty object. } }); return loginview; } );
here form:
<form action="#" id="loginform" class="form-horizontal" role="form"> <legend> <fieldset> <label for="username">username</label> <input type="text" value="" id="username" class="form-control" placeholder="enter username"> <label for="password">password</label> <input type="text" id="password" value="" class="form-control" placeholder="enter password"> <input type="submit" class="btn btn-primary" value="login" id="login"> </fieldset> </legend> </form>
i updated form html adding name
elements. works fine.
here updated html:
<form action="#" id="loginform" class="form-horizontal" role="form"> <legend> <fieldset> <label for="username">username</label> <input type="text" value="" id="username" name="username" class="form-control" placeholder="enter username"> <label for="password">password</label> <input type="text" id="password" value="" name="password" class="form-control" placeholder="enter password"> <input type="submit" class="btn btn-primary" value="login" id="login"> </fieldset> </legend> </form>
Comments
Post a Comment