Osu
Osu

Reputation: 1137

event.layerX error when using click() in jQuery

This is driving me nuts, I can't see the problem. Using jQuery (I'm stuck with v 1.6.2 btw as it's within a CMS), I'm trying to show a div of content by clicking on a link.

Here's my HTML:

        <div id="vl-hcp" class="venue">
            <h1>Title of venue</h1>
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor.</p>
        </div>

<div class="venuesScroller">    
<a href="javascript:void(0);" class="vl-hcp"><span>Title of venue</span></a>
</div>

Here's my jQuery:

    $('.venuesScroller a').click(function(){
        // Make only currently clicked link active and hide other info boxes
        $('.venuesScroller a').removeClass('active');
        $('.venue').addClass('hidden');

        // Make link active and go through cases for showing text
        $(this).addClass('active');
        if($(this).hasClass('vl-hcp')) {
            $('#vi-hcp').removeClass('hidden');
        }
});

But no classes are changed on the venue div when I click the link and in Chrome (version 17.0.963.56), I'm getting the error:

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.

Can anyone see what the issue is? I'm really stuck here.

Thanks,

Osu

Upvotes: 0

Views: 414

Answers (2)

Shad
Shad

Reputation: 15471

It's not an error, it's a warning.

When jQuery normalizes the event object, it iterates over all of the properties that it might have, and when it touches layerX and layerY, Chrome's JS Engine throws the warning.

If the issue is that the hidden class isn't being removed from #vl-hcp, it's because of a typo:

$('#vi-hcp').removeClass('hidden');

should be

$('#vl-hcp').removeClass('hidden');

Upvotes: 1

Alexander
Alexander

Reputation: 23537

I used the below code from here to fix these warnings. This is a workaround to avoid updating the jQuery yet.

(function(){
    // remove layerX and layerY
    var all = $.event.props,
        len = all.length,
        res = [];
    while (len--) {
      var el = all[len];
      if (el != 'layerX' && el != 'layerY') res.push(el);
    }
    $.event.props = res;
}());

More information can be found in the same referring question.

Upvotes: 0

Related Questions