akv2 / MaxImage

The first jQuery plugin to use jQuery Cycle plugin as a fullscreen background slideshow.

Home Page:http://www.aaronvanderzwan.com/maximage/2.0/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

data-href

martijn-dd opened this issue · comments

I've add data-href values to my images. They are applied to the .mc-image div.
However I cannot bind a onclick event on the div.

I've added in the document ready:

$('.mc-image').click(function() {

console.log('working?'); // For testing
});

But no 'working?' in the firebug console.

Also not working:

$('.mc-image').each(function() {
$(this).attr('onclick', 'console.log("working?");');
});

The onclick attribute is added when I inspect the element with Firebug but still no action.

What is the way to add onclick to the div/image?

i got to fire the click event. the thing is you must have no other html element overlaying your maximage container. and you should use the jquery live event because the plugin transforms your images to divs on the fly

you should use jquery like this
$('#maximage').on('click', '.mc-image', function() {
console.log($(this).data()) // will log all data attr
});

now because maximage transforms your images to divs with background images; if you have other containers laying on top of your maximage div, you wont be able to click on the mc-image because it is blocked by the container on top and unfortunately you cant z-index your maximage container to be above everything else otherwise you will only see images

http://jsfiddle.net/tf42y/