Include jQuery document.ready() as an include file
Am I able to include as an include, an external jquery.dialog.js file that consists of the following?
$(document).ready(function(){
$(function(开发者_如何转开发) {
location.hash = 'PAGETOP';
});
$("#dialogou").dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
modal: true,
draggable: true,
position: ["center", 100],
buttons: {
'Ok': function() {
$(this).dialog("close");
closeReq();
}
}
});
});
and then pass this in using the script include notation:
<script type="text/javascript" src="../jquery.dialog.js"></script>
This doesn't seem to work for me.
as long as you include the jQuery's .js file before this dialog one, it should work
I believe $(document).ready(function(){});
and $(function() {});
(a short-hand version) are equivalent, so you should simplify it to just:
$(document).ready(function(){
location.hash = 'PAGETOP';
$("#dialogou").dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
modal: true,
draggable: true,
position: ["center", 100],
buttons: {
'Ok': function() {
$(this).dialog("close");
closeReq();
}
}
});
});
Also, install Firebug so you can see what's being included and from where. It will tell you if you are including your script wrong (probably a 404).
精彩评论