working when referenced like this:
##application.html.erb
<script type="text/javascript">
$(function () {
setInterval("rotateImages()", 2000);
});
function rotateImages () {
var oCurPhoto = $("#slideshow div.current");
var oNxtPhoto = oCurPhoto.next();
if (oNxtPhoto.length == 0)
oNxtPhoto = $("#slideshow div:first");
oCurPhoto.removeClass('current').addClass('previous');
oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity:1.0 }, 1000,
function () {
oCurPhoto.removeClass('previous');
});
}
but not like this:
##application.html.erb
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "jquery-1.4.3" %>
<%= javascript_include_tag "rails" %>
<%= csrf_meta_tag %>
##application.js
(function () {
setInterval("rotateImages()", 2000);
});
function rotateImages () {
var oCurPhoto = $("#slideshow div.current");
var oNxtPhoto = oCurPhoto.next();
if (oNxtPhoto.length == 0)
oNxtPhoto = $("#slideshow div:first");
oCurPhoto.removeClass('current').addClass('previous');
oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity:1.0 }, 1000,
function () {
oCurPhoto.removeClass('previous');
});
}
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
jQuery.noConflict();
That will change the jQuery $ variable to jQuery
See http://api.jquery.com/jQuery.noConflict/ for more information.