2

我想在页面加载时执行一个功能,但不知道该怎么做。因为我有一个列表,但他的数据来自加载中的另一个地方。

4

2 回答 2

5

听起来您正在通过 AJAX 调用刷新页面内容,并且您希望在添加页面加载时进行 AJAX 调用以将其绑定到事件。

假设是这种情况,在 ModelViewModel 声明的末尾,只需调用该函数。例如:

function SearchResultsViewModel(){
    this.updateResults=function(){
      //Some AJAX Call and action.   
    }
    this.updateResults();
}
于 2012-12-05T02:24:27.523 回答
3

您将淘汰视图模型正常绑定到视图,然后使用

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

或在 jQuery 中

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

由于敲除是绑定到视图的,当你添加项目时,视图会自动更新。

于 2012-04-17T16:49:08.597 回答