I am using the jQuery Steps plugin to create a wizard and on step two, you will add 1..* fields, which is an array of JSON objects that'll get posted to the server. I'm trying to use Knockout to show an input for each field name.
On click, a new empty field should get pushed to the array and a textbox should display. However, the addField function doesn't fire when inside the form/jquery steps. If I take it out, it does. Is there a way to prevent jQuery steps from interfering with the binding? Here's a condensed version of the code:
function AppViewModel() {
var self = this;
self.fields = ko.observableArray([]);
self.addField = function() {
// push field to self.fields
}
}
ko.applyBindings(new AppViewModel());
// jQuery Steps
var form = $("#stepsForm");
form.children("div").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
stepsOrientation: "vertical"
});
table {
border: 1px solid blue;
}
td {
border: 1px solid red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-steps/1.1.0/jquery.steps.min.js"></script>
<form id="stepsForm" action="#" novalidate>
<div class="form-container">
<h3>Section1</h3>
<section>
<table class="table table-condensed">
<tr data-bind="foreach: fields">
<td>
<div data-bind="text:FieldName"></div>test
</td>
</tr>
</table>
<button data-bind="click: addField">Add another</button>
</section>
</div>
</form>