[英]Call view javascript function from javascript file
I have a jquery template that is being loaded with values after the ajax call is done and not on the view load. 我有一个jquery模板,它在ajax调用完成后正在加载值,而不是在视图加载时加载。
on page load my javascript calls and function from a script.js file. 页面上从script.js文件加载我的JavaScript调用和函数。 i need that script.js file to call another function from the view.
我需要那个script.js文件从视图中调用另一个函数。 How would i call the listload function from the script.js
我如何从script.js调用listload函数
var limit = 5, dir = ' Desc', sort = 'Created', index = 0, autoscroll = false;
function getDataUrl(index, action) {
return '/Team/Linking/ListItemLinks/@Model.ItemId/?type=@Model.ItemType';
}
function listload() {
alert('test');
}
Corey, 科里
As per my understanding, you will invoke a function in a js file from a view and after that the js file will invokes another function residing in the same view. 根据我的理解,您将在一个视图中的js文件中调用一个函数,此后,该js文件将在同一视图中调用另一个函数。
I think you can achieve it (By theoritically) because, 我认为您可以实现(理论上),因为,
I think jQuery may have similar kind of stuffs, because we are calling jquery using an external file, but after that it calls the next line. 我认为jQuery可能有类似的内容,因为我们使用外部文件调用jquery,但此后它将调用下一行。
Another thing is to check with the callbacks and events in javascript. 另一件事是检查javascript中的回调和事件。 I am not expert in topic.
我不是主题专家。 You can check the following links, may be it helps you.
您可以检查以下链接,可能对您有帮助。 Create a custom callback in JavaScript http://blog.pengoworks.com/index.cfm/2012/1/12/Adding-custom-callbacks-to-existing-JavaScript-functions
在JavaScript中创建自定义回调 http://blog.pengoworks.com/index.cfm/2012/1/12/Adding-custom-callbacks-to-existing-JavaScript-functions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.