I'm trying to implement this in my Ruby on Rails application. The only thing what doesn't work is the Javascript code. I already tried %script and :javascript. But for some reason it doesn't load. When I hover over the radio button it doesn't show anything.
Javascript/jQuery (From jsfiddle):
$(document).ready(function(){
$('#container').on('mouseenter', '#radiobtn', showBox);
$('#container').on('mouseleave', '#radiobtn', hideBox);
function showBox(e){
var x = e.pageX + 20;
var y = e.pageY + 20;
$('#hoverbox').fadeIn();
$('#hoverbox').offset({ left: x, top: y });
}
});
function hideBox(){
$('#hoverbox').fadeOut();
}
Example: http://jsfiddle.net/wrN2u/387/
Own Javascript file:
:javascript
$(document).ready(function(){
$('#container1').on('mouseenter', '#radiobtn', showBox);
$('#container1').on('mouseleave', '#radiobtn', hideBox);
function showBox(e){
var x = e.pageX + 20;
var y = e.pageY + 20;
$('#hoverbox').fadeIn();
$('#hoverbox').offset({ left: x, top: y });
}
});
function hideBox(){
$('#hoverbox').fadeOut();
}
HAML:
!!!
%html
%head
= javascript_include_tag 'options.js'
#container1
%input{:name => "optradio", :type => "radio", :id => "radiobtn"}option1
#hoverbox
#container2
%input{:name => "optradio", :type => "radio", :id => "radiobtn"}option2
#hoverbox2