javascript - Knockout not behaving correctly in Pyramid -
i'm building webapp using pyramid, knockout behaving differently. have form:
<div data-bind="with: $root.itemtoadd" style="display: none;"> <form data-bind="submit: $root.additem"> <fieldset style="border: none;"> <legend >submit item</legend> <label> url <span>{</span> </label> <input type="text" placeholder="url" data-bind="value: url, valueupdate: 'afterkeydown'" /> <br /> <br /> <label> kwip <span>{</span> </label> <input type="text" placeholder="your description please!" data-bind="value: description, valueupdate: 'afterkeydown'" /> <br /> <br /> <button type="button" class="submitanitem">add item</button> <a href="#" class="exit">cancel</a> </fieldset> </form> </div>
here view model:
var viewmodel = function() { this.itemtoadd = { url: ko.observable(""), description: ko.observable("") }; //behavior this.additem = function () { alert('event fired'); }; };
i can't figure out why when form submitted 'additem' function not fired. recreated in framework , able fire event. there happening in pyramid might interfere javascript? can point me in right direction?
it's because type button button not fire submit event. need button type submit fire that