Onload Binding using knockoutjs?

I Want to execute a function when the page load but don't know how to do it. cause that I have a list but his data from to another place in the load.

Answers


It sounds like you are refreshing page content through an AJAX call and you want to make that AJAX call on the page load in ADDITION to binding it to an event.

Assuming that is the case, at the end of your ModelViewModel declaration, simply call the function. For example:

function SearchResultsViewModel(){
    this.updateResults=function(){
      //Some AJAX Call and action.   
    }
    this.updateResults();
}

You bind the knockout viewmodel to the view as normal, then use

window.onload = function ()
{
     //data from to another place in the load
}

or in jQuery

$(document).ready(function(){
     //data from to another place in the load
)};

Since knockout is bound to the view, when you add items, the view will update automatically.


Need Your Help

Illegal string offset error in Wordpress with Advanced Custom Fields

php wordpress wordpress-plugin

I am using advanced custom fields plugin with Wordpress trying to echo out a simple image using the code provided in their instructions.

Find a string in a text file and put it in another fle with regular expressions

regex bash scripting

The idea is i want to get the ID of a virtual machine through euca-describe-instances and put it in a text file with bash scripting.