rhandalthor
asked on
use javscript to trigger onclick event on image in jQuery zoommap
I am using http://www.gethifi.com/blog/a-jquery-plugin-for-zoomable-interactive-maps for an interactive map. I added a legend. One icon on the legend should trigger a clickable region on the map and thereby cause the map to zoom in. How can I create such an oncllick event to make the browser click that zoomable region? Will some CSS do or do I need JavaScript?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Reading http://api.jquery.com/click/ now...
ASKER
I guess I would have to load something like
$('#other').click(function() {
$('#target').click();
});
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Loaded
$('#destinations-legend').click(function() {
$('#kadavu').click();
});
Just to make the whole legend image a trigger. Reloaded the page. No luck yet and an error:$ is not defined
http://abc.com
Line 1
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WordPress normally loads jQuery on the home page and all pages unless blocked and it is loaded on that page. I checked using Firebug. Maybe the legend.js is loaded too late or too early to work with jQuery?
ASKER
Read http://wpengineer.com/2028/small-tips-using-wordpress-and-jquery/ and tried
No luck yet :-(
]jQuery(function ($) {
// Now you can use $ as a reference to jQuery without any problem
$('#destinations-legend').click(function() {
$('#kadavu').click();
});
});
in legend.js which I load using
wp_enqueue_script('legend', '/wp-content/themes/decondo-child/lib/scripts/legend.js');
No luck yet :-(
do you url to page that I can take a look at the error messages?
ASKER
Site is not open to the public yet. I see this error:
when I use this
in legend.js
$ is not defined
http://abc.com
Line 1
when I use this
$('#destinations-legend').click(function() {
$('#kadavu').click();
});
When I check other script loaded i DO see jQuery JavaScript Library v1.4.2 . legend.js is loaded before jQuery in the header.in legend.js
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Trying to figure out how to do that with the WordPress'
wp_enqueue_script('legend', '/wp-content/themes/decondo-child/lib/scripts/legend.js');
in function.php. Never done that before..ASKER
wp_enqueue_script('legend', '/wp-content/themes/decondo-child/lib/scripts/legend.js','jquery');
was supposed to load the script and make it clear to WordPress that it depends on jQuery, but I still get
jQuery is not defined
http:/abc.coms?ver=3.0.1
Line 1
using jQuery(document).ready(function ($) {
$('#destinations-legend').click(function() {
$('#kadavu').click();
});
});
ASKER
OK. Working. Had to load it before wp_head() in the parent theme :-)
ASKER