Here is the situation. I've 2 views: grid-view and add-view. When page loads, grid-view is visible. By clicking on "New" button, add-view comes into the picture. Both views are into the layout.Here's the code:
"New" button is inside customer-search-view-template.
When "New" button is clicked, it triggers newCustomerClicked event and displays add-view. add-view has a form to add a new customer. The form is nested inside a <div>.
Each template has a wrapping element.
I've tried to bind viewmodel customerAdd with form, with parent div, with container div but none of these worked.
I couldn't figure out what is the issue with binding here.
So, how do I bind viewmodel customerAdd with form ?????
var customerSearchLayout = new kendo.Layout($('#customer-search-view-template').html()); customerSearchLayout.render($("#searchCust")); var addCustomerView = new kendo.View($('#add-customer-view-template').html()); var customerGridView = new kendo.View($('#customer-grid-view-template').html()); var layout = new kendo.Layout("<div id='content' class='contentDiv'></div>"); layout.render($("#main")); layout.showIn("#content", customerGridView);"New" button is inside customer-search-view-template.
var customerSearch = kendo.observable({ customerName: "Customer name", searchClicked: function() { this.set("customerName", "Search clicked"); }, newClicked: function(e){ e.preventDefault(); this.trigger("newCustomerClicked"); } }); customerSearch.bind("newCustomerClicked", function(){ layout.render($("#main")); layout.showIn("#content", addCustomerView, "swap"); }); // Bind the view model to the customer element. kendo.bind($('#searchCustomer'), customerSearch);When "New" button is clicked, it triggers newCustomerClicked event and displays add-view. add-view has a form to add a new customer. The form is nested inside a <div>.
<form id="addCustForm"><label for="txtFname">First name</label> <input id="fname" data-bind="value: firstName" class="k-textbox" /></form>// observable object of add customer var customerAdd = kendo.observable({ firstName: "Hello world!" }); // Bind the view model to the customer element. kendo.bind($('#addCustForm'), customerAdd);Each template has a wrapping element.
I've tried to bind viewmodel customerAdd with form, with parent div, with container div but none of these worked.
I couldn't figure out what is the issue with binding here.
So, how do I bind viewmodel customerAdd with form ?????