In require JS in asp.net MVC i am trying to access the variable and method used in another module. How to do it ? Provided my example as below
- ParentPageA
Below JS For ParentPageA
require([ 'jquery', 'bootstrap', 'jqGrid'], function ($){
$(function () {
var messageToAlert = 'Sample Message'; //Message Could be dynamic
function DOWork(){
alert('hi'); //Or other code using Jquery table
alert(messageToAlert);
messageToAlert = 'Change message ';
}
});
}
PartialViewA In ParentPageA
require([ 'jquery', 'bootstrap', 'jqGrid', 'ParentPageA'], function ($,ParentPageA){ //ParentPageA - is Undefined $(function () { //How to Access messageToAlert variable ? //How to Access DOWork() //Need to access back the changed MessageToAlert variable as well }); }
Is define the only option ? if i use Define - will it still be able to load other dependent modules inside the define ? Since my functions & variables depend on other libraries to be able to run (like funcions which Jquery, Calendar etc...).