Created
May 27, 2013 13:35
-
-
Save royling/5657085 to your computer and use it in GitHub Desktop.
An example of using seajs with jquery & jquery plugin (dataTables)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style type="text/css"> | |
#tbl1 { | |
table-layout: fixed; | |
width: 500px; | |
border-collapse: separate; | |
border-spacing: 0; | |
border: 1px solid #afafaf; | |
} | |
th, td { | |
width: 100px; | |
border-style: solid; | |
border-width: 0 1px 1px 1px; | |
border-color: #fff #afafaf #afafaf #fff; | |
} | |
th { | |
background-color: #ebedef; | |
} | |
</style> | |
</head> | |
<body> | |
<p id="p1">Hello world!</p> | |
<table id="tbl1"> | |
<thead> | |
<tr> | |
<th>A</th> | |
<th>B</th> | |
<th>C</th> | |
</tr> | |
</thead> | |
<tbody> | |
</tbody> | |
</table> | |
<!-- | |
<script src="lib/jquery.js"></script> | |
<script src="lib/jquery.dataTables.js"></script> | |
--> | |
<script id="seajsnode" src="seajs/sea.js" data-config="src/config" data-main="src/main"></script> | |
<!-- | |
<script> | |
seajs.use('jquery', function($) { | |
$('#p1').css({ | |
'background-color': 'lightgreen', | |
'width': '200px' | |
}); | |
$.each(['a', 'b', 'c'], function(i, v) { | |
console.log(i, v); | |
}); | |
}); | |
seajs.use(['jquery', 'dataTables'], function($) { | |
var dt = $('#tbl1').dataTable({ | |
//sDom: 't', | |
bAutoWidth: false, | |
aaData: [ | |
['a', 'bbb', 'ccccccccc'] | |
] | |
}); | |
setTimeout(function() { | |
dt.fnAddData([ | |
['hello', 'data', 'tables'] | |
]); | |
}, 1000); | |
}); | |
</script> | |
--> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seajs.config({ | |
plugins: ['shim'], | |
alias: { | |
'jquery': { | |
src: 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', //'lib/jquery.js', | |
exports: 'jQuery' | |
}, | |
'dataTables': { | |
src: 'http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js', //'lib/jquery.dataTables.js', | |
deps: ['jquery'] | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require) { | |
var $ = require('jquery'); | |
require('dataTables'); // load jquery.dataTables | |
//seajs.use('jquery', function($) { | |
$('#p1').css({ | |
'background-color': 'lightgreen', | |
'width': '200px' | |
}); | |
$.each(['a', 'b', 'c'], function(i, v) { | |
console.log(i, v); | |
}); | |
//}); | |
//seajs.use(['jquery', 'dataTables'], function($) { | |
var dt = $('#tbl1').dataTable({ | |
//sDom: 't', | |
bAutoWidth: false, | |
aaData: [ | |
['a', 'bbb', 'ccccccccc'] | |
] | |
}); | |
setTimeout(function() { | |
dt.fnAddData([ | |
['hello', 'data', 'tables'] | |
]); | |
}, 1000); | |
//}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment