Im trying to use the movingBoxes plugin with my asp.net mvc site and it is not working (obviously). I have the movingboxes.js imported in my head tag in the site.master like so
<script src="<%: Url.Content("~/Scripts/jquery.movingboxes.js")%>" type="text/javascript"></script>
and the browser successfully gets this script. Now i have a regular view that inherits from the site.master that has this little bit of jquery in it that calls the movingBoxes plugin
<script type="text/javascript">
$(document).ready(function () {
$($('#slider-one'));
$('#slider-one').movingBoxes({
startPanel: 1,
panelWidth: .5,
fixedHeight: false
});
$('#slider-two').movingBoxes({
startPanel: 1,
panelWidth: .5,
fixedHeight: false
});
});
</script>
When i view the page. Every thing works fine (including other jquery stuff) except for this plugin and i get this error
And here is the description of the error
Any help would be appreciated
EDIT
So apparently I had this:
<script type="text/javascript" src="../../Scripts/jquery-1.4.1.js" />
<script src="<%: Url.Content("~/Scripts/jquery.movingboxes.js")%>" type="text/javascript"></script>
And it works now by changing it to this:
<script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script>
<script src="<%: Url.Content("~/Scripts/jquery.movingboxes.js")%>" type="text/javascript"></script>
There are a few things you can try to get this working.
Be ABSOLUTELY sure your script is being pulled into the page, one way to check is by using the 'sources' tab in the Chrome Debugger and searching for the file.
Be sure that you've included the script after you've included jQuery, as it is most certainly dependant upon that.
Other than that, I checked out the API and you're definitely doing everything right as far as I can see. Best of luck friend!
EDIT: Ensure you close your script tag. There's an answer below that points to that being the solution.
Please keep in mind that only a few elements can be self-closing, most others have to be closed through adding an explicit end tag. In the above case, the first script tag was not closed properly, the end script tag of the second script then closed the script section, causing only the first script to be loaded as external script source and ignoring the second script.
More info about which tags can be self-closed, have a look at the W3C drafts for HTML5 (although the definition was no different in earlier HTML-versions):
http://www.w3.org/TR/html5/syntax.html#end-tags (8.1.2.1, Point 6)
I had the same problem. I changed the order of the scripts in the head part, and it worked for me. Every script the plugin needs - needs to stay close.
For example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#slider').cycle({
fx: 'fade'
});
});
</script>