javascript - KnockoutJS submit binding not working with foreach -


hello unable use knockout 'submit' binding 'foreach' binding. cannot figure out mistake here. please me find mistake.

my view model this:

function poreceivingmodel(){     var self = this;     var initial_row = new poreceivingrowmodel();     self.rows = ko.observablearray([initial_row]);     self.saveandadd = function(formelement){         alert('entered function');         var row = new poreceivingrowmodel();         self.rows.push(row);     }; };  function poreceivingrowmodel(){     var self = this;     self.building = ko.observable();     self.isele_abc = ko.observable();     self.isele_num = ko.observable();     self.isele_floor = ko.observable(); }; 

and html binded 'viewmodel' this:

<tbody data-bind="foreach: rows">     <form data-bind="submit: $parent.saveandadd">         <tr>             <td>                 <!-- input field here -->             </td>              <td>                 <!-- input field here -->             </td>              <td>                 <!-- input field here -->             </td>             <td>                 <!-- input field here -->             </td>             <td>                 <button type="submit">save , add</button>             </td>          </tr>     </form> </tbody> 

the problem when click on 'add , save' button 'saveandadd' function 'poreceivingmodel' not called. not alert message. tried calling function 'click' binding on 'button' element. function called way ie alert message.

update: in firebug see form tag closed after , button out of 'form' tag.

i found form tag cannot used inside table tag. solution table tag can put inside form tag . if not want can change table tag div may not give desired output.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -