• Resolved freerange

    (@freerange)


    Here is what happens:

    Slimstat checks at install time for onClick before attaching to the click event of <a> elements. This means that any click event handlers added by other code after slimstat installs get missed. When the user clicks the link the new event handler runs and calls .preventDefault() which should stop the link from being followed but instead slimstat_track_link() simulates the click anyway leading to unpredictable results. This is particularly a problem with jQuery because it tends to bind .click() late due to the use of .ready()

    The fix is probably to check for the presence of other click handlers in slimstat_track_link() and bail if you find more than one total.

    Click the ‘RepostUs’ button on this page to see this happening http://juliasherred.com/2011/05/dan-freeman-interview/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jason Crouse

    (@coolmann)

    Hi there,

    Unfortunately I don’t think there’s a way to do that in JavaScript (I’m not using jquery). But you can add class=noslimstat to the links you want to “protect”. Wp slimstat will just skip them

    Camu

    Thread Starter freerange

    (@freerange)

    Doh! You’re right – I get so used to jQuery I forget you can’t do some things generically.

    Do you check for .noslimstat at runtime or only when you install the event handler ?

    Plugin Author Jason Crouse

    (@coolmann)

    Runtime 🙂 when users click, the event handler will check for that class and if it exists, will not disturb the other handlers installed (append)

    Camu

    Thread Starter freerange

    (@freerange)

    I fixed it another way – the href is really only a fallback in case the JS fails so when I attach the click event in jQuery I now replace the href with a javascript:void(0); which seems to do the trick and should work for anybody else doing similar things.

    Thanks for your help.

    Plugin Author Jason Crouse

    (@coolmann)

    Okay, but I guess the class is easier for people who don’t have this kind of skills 😉 Not everybody is a javascript “guru” 😀

    Camu

    PS: a vote for my plugin would be greatly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP Slimstat] firing on links that have jQuery .click() actions’ is closed to new replies.