Reputation: 29271
I am currently loading a model with jQuery's .load. After it has been successfully loaded, I would like to execute some JavaScript which has dependencies on the loaded model.
buildFindOrderDialog: function () {
workflowDialogContent.load('../../csweb/Orders/FindOrderDialog/', function () {
$.getScript('~/Scripts/FindOrderDialogModel.js');
workflowDialog.dialog('open');
});
}
The load method executes the Order Controller's FindOrderDialog method which returns a ViewModel. After this has loaded, I want to run my FindOrderDialogModel javascript to affect the model client-side.
The above code does not properly load the javascript. I am wondering: does my controller have to provide a method for loading the javascript? The client has no concept of the relative path.
Of course, I could inline the script with the FindOrderDialog view, which would cause it to execute after load, but this seems like a bit of a hack.
UPDATE: My syntax was just a bit off. This works:
buildFindOrderDialog: function () {
workflowDialogContent.load('../../csweb/Orders/FindOrderDialog/', function () {
$.getScript('../Scripts/Orders/FindOrderDialogModel.js');
workflowDialog.dialog('open');
});
},
Upvotes: 0
Views: 824
Reputation: 1000
If I understand your question correctly, how about either
$.getScript('Scripts/FindOrderDialogModel.js');
Alternatively specify the full path:
$.getScript('/My/Full/Path/Scripts/FindOrderDialogModel.js');
Or finally, inject the relative path via ASP.NET:
$.getScript('<%= .NET CODE FOR RETRIEVING PATH USING THE ~ SIGN %>');
Upvotes: 1