XF 2.3 Can you trigger two events with data-xf-click?

frm

Well-known member
Is it possible to trigger two (or more) different data-xf-click events at once?

One is already there to count link clicks, but I want to trigger an overlay prior to going to the link such as a "You are leaving this site..." type of one.

Would I need to first do an overlay and then trigger the link click counter on the 2nd link when they actually visit the site?

Or, can I do something like data-xf-click="overlay linkcounter"?
 
Still wondering if this is possible before I make it a suggestion, much like the rel attribute in the <a> tag allowing for "noopener nofollow ugc".

I have no way of testing this out unless I ask a developer to develop a custom add on to achieve something else I want to log or do with a click, and I'm unsure if that's even possible with the lack of responses here.

More specifically, I'm trying to track click counts and display an overlay at the same time with something like "overlay linkcounter".

Edit: I'd also like to pass the thread id or something else into the overlay by potentially grabbing the thread id from data-xf-click for reporting issues, if it can't already get that from the link it overlays with, such as "overlay linkcounter threadid1".
 
Last edited:
Would I need to first do an overlay and then trigger the link click counter on the 2nd link when they actually visit the site?
Actually, you would need to do this unless you want to trigger both JS handlers when the overlay is opened (regardless of whether they interact with it or not). Essentially data-xf-click just provides a way to fire a JS function when the element is clicked.

Could it pass a variable like threadID1 or would that have to be in the add on to capture it from the link it's given like /overlay/threadID1 as the href for the overlay?
Presumably you would add the handler to the attribute using a template modification from the add-on to begin with. The handler has access to the element via this.target, so you can derive information from the DOM if possible, or pass in options via data-* attributes.
 
Actually, you would need to do this unless you want to trigger both JS handlers when the overlay is clicked (regardless of whether they interact with the overlay or not). Essentially data-xf-click just provides a way to fire a JS function when the element is clicked.


Presumably you would add the handler to the attribute using a template modification from the add-on to begin with. The handler has access to the element via this.target, so you can derive information from the DOM if possible, or pass in options via data-* attributes.
Thanks for the clarification.

I think I have enough information gathered to get it to do what I want to do.
 
Back
Top Bottom