var index = 0;
var interval = null;
var image = document.getElementById("image");
var imagesURLs = [
"http://placehold.it/260x150",
"http://placehold.it/265x150",
"http://placehold.it/270x150",
"http://placehold.it/275x150"
];
image.onmouseover = function(){
interval = setInterval(function(){
if(!imagesURLs[++index]){
index = 0
}
image.src = imagesURLs[index]
}, 1000);
};
image.onmouseout = function(){
clearInterval(interval)
};
Array.from(container.childNodes).filter(function(child){
return child.classList && child.classList.contains('go')
})
match 'url' => 'controller#method', :constraints => { :only_ajax => true }
class BooksController < ApplicationController
before_action :access_check, only:[:new]
def new
@book = Book.new
form_html = render_to_string( :partial => 'books/form', :formats => [:html], :locals => { :book => @book } )
render :json => { :form_html => form_html }
end
private
def access_check
unless request.xhr?
redirect_to :root_path
end
end
end