Writing and submitting a form view with Ember.js -


i'm working on proof of concept demo , need write form view let me add items content array. i'm loading view externally compiling using handlers. i've added submit method , used {{action}} binding each time click submit button reloads page. missing?

// template

<form>     <div>         <label for="client">client name</label>         <input type="text" id="client" placeholder="add client name" />     </div>     <div>         <button {{action "addclientsubmit" target="pm.addclientview"}}>add client</button>     </div>     <div>         <a href="#" {{action "closewindow" target="pm"}}>close</a>     </div> </form> 

// view code

pm.addclientview = ember.view.create({     templatename: 'addclient',     classnames: 'overlay',     addclientsubmit: function(e){         e.preventdefault();         console.log('submitting add client form');         console.log(a,b,c)     } }); 

// , here's how i'm adding page

pm = ember.application.create({     loadview: function(view){         $.ajax({             url: viewpath,             success: function (template) {                 if (!ember.templates[templatename]) {                     ember.templates[templatename] = ember.handlebars.compile(template);                 };                 pm[view + 'view'].appendto('body');             }         });     } }); 

everything else works, when click submit button page reloads. i'm sure i'm leaving out can't figure out is.

you need add type="button" button tag. default type="submit" trigger form submission.

here's jsfiddle: http://jsfiddle.net/b2ctg/2/


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -