Reputation: 331
$(document).ready
will only be executed if I add a breakpoint via firebug and continue from there or an alert before the line var buttons
. Otherwise it does nothing.
$(document).ready(function () {
//alert('sdfsdf');
var buttons = $(".modalInput").overlay({
mask: {
color: '#ebecff',
loadSpeed: 200,
opacity: 0.9
},
closeOnClick: false
});
});
I work with Mvc2 and use Telerik Components.
Any suggestions?
Upvotes: 0
Views: 769
Reputation:
Do you include the jquery-source before this script block?
Wrong would be:
<script type="text/javascript">
$(document).ready(function () {
//alert('sdfsdf');
var buttons = $(".modalInput").overlay({
mask: {
color: '#ebecff',
loadSpeed: 200,
opacity: 0.9
},
closeOnClick: false
});
});
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
whereas following would be correct
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//alert('sdfsdf');
var buttons = $(".modalInput").overlay({
mask: {
color: '#ebecff',
loadSpeed: 200,
opacity: 0.9
},
closeOnClick: false
});
});
</script>
By the way, does your alert work?
Upvotes: 0
Reputation: 66389
The elements with "modalInput" probably have their own initialization code occurring on window load event, and this code has not yet executed when you have your own code.
Correct solution will be to catch some sort of "Completed" event of those elements, maybe Telerik component expose such thing?
Quick and dirty solution will be to use timer (window.setTimeout) and have your code executed for example one second after the document is ready.
Upvotes: 0
Reputation: 13292
If it works when you alert and when you set a breakpoint, it sounds like the problem is with your set up of the overlays and not with the ready function at all. Can you post some HTML code for the overlays are working on?
Upvotes: 1