Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-href #11

Open
martijn-dd opened this issue Nov 13, 2012 · 1 comment
Open

data-href #11

martijn-dd opened this issue Nov 13, 2012 · 1 comment

Comments

@martijn-dd
Copy link

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?

@barohatoum
Copy link

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants