//main.js
require.config({
baseUrl: '../Scripts/lib/',
paths: {
'jquery': 'jquery-2.0.0',
}
});
define(['jquery', '../test1'], function ($, object) {
$(document).ready(function () {
$('#button').bind('click', function () {
object.getsomething();
});
});
});
//
//main1.js
require.config({
baseUrl: '../Scripts/lib/',
paths: {
'jquery': 'jquery-2.0.0',
}
});
define(['jquery', '../test1'], function ($, object) {
$(document).ready(function () {
$('#button').bind('click', function () {
object.getsomething2();
});
});
});
//
//test1.js
define(function () {
return {
getsomething: function(){
$('#button').css({'background-color':'#000'})
},
getsomething2: function(){
$('#button').css({'background-color':'#000'})
}
}
//return shit;
});
//
//Default1.aspx
<script data-main="<%: ResolveUrl("~/Scripts/main.js") %>" src="<%: ResolveUrl("~/Scripts/lib/require.js") %>"></script>
//Default2.aspx
<script data-main="<%: ResolveUrl("~/Scripts/main1.js") %>" src="<%: ResolveUrl("~/Scripts/lib/require.js") %>"></script>
is it a must to declare require.config in every page that want to use the jquery? Cant I share to use the main.js in different pages? I kinda lost now, I thought it suppose to share the require.config among all the page, and each page should have their own js, and requirejs will help to put the thing that I want, as requirejs only can point to js that have require.config? search through google, still cant make up my mind on how to use on multiple page and script, need some guideline to clear out my mind
Update:1
//main.js
require.config({
baseUrl: '../Scripts/lib/',
paths: {
'jquery': 'jquery-2.0.0',
}
});
});
//
//Scripts/script1.js
define("main",['jquery', '../test1'], function ($, object) {
$(document).ready(function () {
$('#button').bind('click', function () {
object.getsomething();
});
});
//
//Scripts/script2.js
define(['jquery', '../test1'], function ($, object) {
$(document).ready(function () {
$('#button').bind('click', function () {
object.getsomething2();
});
});
//test1.js
define(function () {
return {
getsomething: function(){
$('#button').css({'background-color':'#000'})
},
getsomething2: function(){
$('#button').css({'background-color':'#000'})
}
}
//return shit;
});
//
//Default1.aspx
<script data-main="<%: ResolveUrl("~/Scripts/main.js") %>" src="<%: ResolveUrl("~/Scripts/lib/require.js") %>"></script>
<script src="./Scripts/script1.js">
//Default2.aspx
<script data-main="<%: ResolveUrl("~/Scripts/main.js") %>" src="<%: ResolveUrl("~/Scripts/lib/require.js") %>"></script>
<script src="./Scripts/script2.js">
I had re go through again every single tutorial and page, and come out something like this, is it correct to code like this? but it hit error, unless i remove the external script from the source