1

I have a jquery template that is being loaded with values after the ajax call is done and not on the view load.

on page load my javascript calls and function from a script.js file. i need that script.js file to call another function from the view. How would i call the listload function from the script.js

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 Toolis
  • 307
  • 1
  • 3
  • 21
  • is said function declared globally or on the window, or any object defined on the window? if not, then it's not possible. – Kevin B Jul 23 '13 at 18:36

1 Answers1

0

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.

I think you can achieve it (By theoritically) because,

  1. When the page loads, it will clubs all the js.
  2. Consider, if your js file points to a Master/layout page , when the inner page loads it will have the cumulative js (from page,outside js files and master/layout pages). So you can call the function residing in the page from js (need to verify).

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.

Another thing is to check with the callbacks and events in 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

Community
  • 1
  • 1
kbvishnu
  • 14,760
  • 19
  • 71
  • 101