I'm building a webapp using Pyramid, but Knockout is behaving differently. I have a 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 is the 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 the form is submitted that the 'addItem' function is not fired. I recreated this in another framework and was able to fire the event. Is there something happening in Pyramid that might interfere with my javascript? Can someone point me in the right direction?