Hey there, I'm working on a div that contains a map. My goal is to have the width of the div change from 80% to 50% when a user hovers over it. This will create space on the right side for an image to appear.
I've been looking up examples of jquery event handling online and tried implementing it in my app. However, it seems like I may have missed something because there's no response to the mouseover action. If anyone could help me troubleshoot this issue, I would greatly appreciate it. I'm new to web development, rails, and jquery.
Here are the relevant files from my rails project:
list.html.erb - contains all the HTML
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=Q&sensor=false"></script>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application'%>
<%= stylesheet_link_tag 'listings' %>
<body onload="initialize()">
<div id="control_panel">
<input type="button" onclick="getlistings();" value="Add Markers">
<input type="button" onclick="clearMarkers();" value="Remove Markers">
</div>
<div id="info"></div>
<div id="map_canvas" onmouseover="moveLeft();" ></div>
</body>
map.js.erb - contains the javascript and jquery functions
function moveLeft()
{
$(function(){ $("#map_canvas").bind("mouseover", shiftLeft) });
$(function(){ $("#map_canvas").bind("mouseleave", shiftLeft) });
}
function shiftLeft(evt)
{
$("#map_canvas").toggleClass("shifted_mapCanvas");
}
css file:
#map_canvas
{
width: 90%;
height: 90%;
margin-left: auto;
margin-right: auto;
html
{
height: 100%
}
body
{
height: 100%;
margin: 10;
padding: 10
}
}
.shifted_mapCanvas
{
width: 50%;
height: 90%;
margin-left: auto;
margin-right: auto;
html
{
height: 100%
}
body
{
height: 100%;
margin: 10;
padding: 10
}
}