I'm trying to make a popover which has a html-form and a button with type "submit". This popover is also bound to knockout.js.
When I click the button on the popover, it does not trigger the KO function, instead it makes a standard post request.
If I move my form to outside of the popover, it works fine.
How can I create a html-form in a popover and trigger a function of my model with submit button?
Here is a non-working fiddle
<a href="#" id="createTaskPopover" data-toggle="popover" data-placement="right" title="Create Task">Click me!!!</a>
<div id="createTaskPopoverContent" class="hide">
<form data-bind="submit: AddTask">
<input type="hidden" id="FeatureId" name="FeatureId" value="" />
<span>Name</span>
<input type="text" id="Name" name="Name" style="width:100%;" /><br />
<br />
<button id="btnCreateNewTask" type="submit" class="btn btn-info">Create</button>
<br />
</form>
</div>
$('#createTaskPopover').popover({
container: 'body',
html: 'true',
content: function () {
return $("#createTaskPopoverContent").html();
}
});
function VM() {
var self = this;
self.AddTask = function (formElement) {
console.log(formElement);
}
}
var projectVM = new VM();
ko.applyBindings(projectVM);
.html(), so it's losing thesubmitbinding at that point. I don't have a workaround as yet though... - James Thorpe