Custom event rule not firing in Adobe DTM - adobe-analytics

I'm using DTM to listen for an event-based rule, named "My Custom Rule". The event type is "custom", as I'm using custom events to track actions from a 3rd party widget. This is my configuration below. It's fairly bland, and I have no conditions (yet). The custom event name is "my-widget-loaded".
Within my 3rd party widget, I trigger my custom event:
document.dispatchEvent(new CustomEvent('my-widget-loaded'));
In the console, I see:
SATELLITE: detected my-widget-loaded on #documentument
But it never fires my rule, I never see a message like:
SATELLITE: Rule "My Custom Rule" fired.
I have verified that I can create custom event handlers within the console and they fire just fine.
What can I do to make my rule fire? Why isn't it working?

DTM (and Launch) does not properly listen for custom events when using document as the Element or Tag Selector. Use body (and document.body.dispatchEvent) instead.

Related

Is it possible to do a "a href" in corona using lua

I am new to Corona and Lua.
is it possible to do something like an "a href" in Lua? I am having a button and I need it to link it to other page but I can't seem to find a way to do it. I am not trying to infuse HTML code to Lua. I just need a way to perform a function like this(in Lua language). I have googled and even look at the manual of Lua and corona docs but still unable to find anything similar to it.
To people who know this, please advice. Thankss
Clicking a button will cause an event. You can implement a function that handles this event and for example shows another page. Please read the Corona manual and do some basic tutorials. All information you need is there.
From: https://docs.coronalabs.com/api/library/widget/newButton.html
onPress (optional) Listener. An optional function to be called when
the button is pressed. The callback function does not require testing
for event.phase since it only honors "began".
https://docs.coronalabs.com/api/type/Listener.html
Events are dispatched to listeners. Event listeners can be either
functions or table objects.
In both cases, when an event occurs, the listener will be invoked and
be supplied with a table representing the event. All events have a
name property that corresponds to the name you use to register the
event.
For more information, see the Basic Interactivity and Event Detection
guide.
https://docs.coronalabs.com/guide/events/detectEvents/index.html
To find out how to switch "pages" or scenes read
https://docs.coronalabs.com/guide/system/composer/index.html
For adding a reference in a button:
local button =
div {
a{["data-toggle"]="modal",
["data-backdrop"]="static",
href="#refrence-modal",
}
Or, you may add button inside a form:-
define the action of the form
make the button type as submit

jQuery UI Widget factory calling _hoverable (etc.) multiple times

In a widget, I'm adding a refresh method and I need to cleanup everything before re-applying all the hooks. However, I'm not sure what are the consequences of calling this._hoverable(selector); multiple times on the same elements.
Looking inside jquery-ui-1.10.js, I see that the widget factory keeps a jQuery object of the elements, and it performs an add operation with the selector. While I assume it wouldn't add duplicate DOMelements, it's more the next operation : _on that makes me doubt.
Is it ok to call _hoverable and such multiple times on the same element?
No, you should not do that. Calling _hoverable() more than once on an element will register additional handlers on the mouseenter and mouseleave events.
If you absolutely have to call this method more than once, you will have to unbind these handlers beforehand:
this._off(element, "mouseenter mouseleave");
this._hoverable(element);
Note the events are namespaced under the hood, so the call to _off() above will only unbind the handlers registered through _on(), not additional handlers you may have registered yourself.

Zeptojs on() not triggering

I have build a plugin (pluginA) based on zeptojs and inside this plugin I fetch data using ajax and attach a list of
How do I bind an event to these anchors? I was going for something globally like and then use $('[data-key]').pluginB() and then inside pluginB() have something like
$(this).on('click', function (e) { e.preventDefault(); ... }); but I am not able to bind the click event to anchors created dynamically.
I tried adding $('a').on('click', ...) before I call pluginA() but it's not firing.
What I really would like would be to use the bind() trigger() approach in order to decouple the two plugins, but I am having trouble finding a good example.
Use the delegating form of on to bind all desired links in a particular area (in this example, the entire body):
$(body).on('click', 'a[data-key]', function(e) {e.preventDefault();...});
Now all links with data-key will trigger your function, regardless of whether or not they were present at the time you called on; subsequently-added links will automatically get the behavior, and removed links won't leak memory by holding dangling handler references.

Backbone.js focus event fires two events focus and focusin

The view part of my code using Backbone.js is something like this:
var myView = Backbone.View.extend({
events: {
'focus .cell input' : "updateCurrentCell"
},
updateCurrentCell: function(event) {
console.log('updateCurrentCell called');
// Update the current cell.
}
}
Whenever the input element gets focus, the function is called twice. I tried printing the stack trace using console.trace(). It shows that once the function call originated from focus event while the next time from focusin.
My attempts to find out how to prevent one of these events getting fired lead me nowhere.
How can I fix this?
Backbone.View uses delegateEvents to bind the events listed in your events object. If you take a look at the source, you'll see that delegateEvents uses jQuery.delegate to do so.
There's a note in the jquery docs for .focus() that's probably relevant:
The focus event does not bubble in Internet Explorer. Therefore,
scripts that rely on event delegation with the focus event will
not work consistently across browsers. As of version 1.4.2, however,
jQuery works around this limitation by mapping focus to the focusin
event in its event delegation methods, .live() and .delegate().
In theory, this should just work fine, but since you're getting both, perhaps you could try to just listen for the .focusin() event, as it supports the kind of event bubbling .delegate() listens for and is what jQuery is trying to map 'focus' to anyway.

How do you unwire an action in Nitrogen?

In Nitrogen, the Erlang web framework, you wire actions like this:
wf:wire(send_message, #event { type=click, postback=send_message })
but if after that you run
wf:wire(send_message, #event { type=click, postback=send_message2 }),
then you get the action wired twice.
How do you unwire the previous action or all actions of an element?
Since events in nitrogen are bound using jquery's bind method. You can use unbind to unbind them. There isn't currently a nitrogen api to unbind an event but you could output the javascript code to unbind it yourself if you so wished.
see action_event.erl for an example of how the binding javascript is output. You can create a similar action/event that removes the binding.
I too was looking for an "unwire" and didn't find it. My work-around was to wf:replace() the element to which the event was wired, and wire the replacement element; I hope that javascript will eventually notice the former bind can never be called and then garbage collect it. I don't know how expensive such abandoned bindings are. My context was a lazy loading of the page, such that a button would initially show a stub, but when clicked would download arbitrarily large content, and henceforth toggle hide/show.
Beyond being nervous about the sophistication of the javascript garbage collection, I'm worried that this may be a bad pattern, and would love to hear others' experience. The only alternative that occurs to me would be to keep state (e.g. data) in the original element and pass that state back with the event message so that the same event handler would act on the "unloaded->loaded_show->loaded_hide->loaded_show" transitions. But I'd prefer not to be calling back to the server for a simple hide/show transition.

Resources