Oleg
Oleg

Reputation: 1

Create highslide clicks events in jQuery(document).ready

I have the following html code for

<td><a href="url_to_large_image" class="myClass"><img alt="" src="url to trumb" /></a></td>

I try to add the library highslide.Js

jQuery(document).ready(function() {
    $('.myClass a').each(function() {
        $(this).click(function() {
            my res = hs.expand(this);
            alert(res); // false
            return false;
        });
    });
});

When i click on the link the browser reloads the page and shows url_to_large_image, although the method returned false !!

But! If the page already has a following links for highslide, it all works

<td><a href="url_to_large_image1" class="myClass"><img alt="" src="url_to_trumb1" /></a></td>
<td><a href="url_to_large_image2" "return hs.expand(this)"><img alt="" src="url_to_trumb2" /></a></td>

In this case, click the url_to_large_image1 open highslide's popup...

How to solve a problem? Thank you in advance

Upvotes: 0

Views: 233

Answers (2)

Muhammad Amjad
Muhammad Amjad

Reputation: 326

You need to return the object rather then returning a false.

Try the code below

return hs.expand(this);

Upvotes: 0

optimisticupdate
optimisticupdate

Reputation: 1689

I guess it's a problem with your selector

$('.myClass a')

will select all a-tags inside of myClass.

Try to use .myClass only to select your a-tags.

jQuery(document).ready(function() {
$('.myClass').each(function() {
    $(this).click(function() {
        my res = hs.expand(this);
        alert(res); // false
        return false;
    });
});
});

Upvotes: 1

Related Questions