javascript - Load data into a Knockout component via AJAX call -


I request that when partial view and user control is loaded with ASP.NET with some data. After looking at the knockout components, I tried to know how to do something similar to the documentation, but could not understand it.

Can someone help me, load a knockout component based on a table filled data, and the clicked line?

  & lt; Data-bind = "foreach: unapproved notes" & gt; & Lt; TR & gt; & Lt; Td> & Lt; a href = "#" data-bind = "click: fetch note (id))" & gt; Get this record & lt; / A & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; div id = "note-preview-template" & gt; & Lt; Customer-Information Parameters = "???" & Gt; & Lt; / Client-Notification & gt; & Lt; / Div & gt; ko.components.register ('client-information', {viewModel: function (params) {var self = this; self.someProperty = params.}}, template: {element: 'note-preview-template'}} ); self.fetchNote = function (id) {// AJAX call that returns data & lt; Client-Notification & gt; Will load in; }   

Therefore clicking on the link will load component data on AJAX call demand. I do not need to load the component on page load, but I would like to use the component again in my application with similar behavior.

Is it worth using the components or should I just create another view modell, all the functionality is wrapped in it?

Just use the GetJson of Jquery (as Jason to provide your customer) once If you receive the data through that method, then it applies to your observational array ...

Good practice is to remove the underlying array of ignored and push the values ​​of each other after the other , Then mark the hypothesis as mutated in the array

Once you get Jason from the server , Then this post should help you update your observable array:

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -