Where I can find the body of triggerd event in MarionetteJS - backbone.js

I am new to MarionetteJs I have code in my project
_onClick: function(event){
this.trigger('selected');
}
Where I can find the body of this event , I want to go the definition to this event , please help

Related

GA4 Google Analytics event doesn't appear as conversion

I'm using Google Tag Manager(react-gtm-module) package) to push custom events to Google Analytics. In code i do it like this:
GTM.dataLayer({ dataLayer: { event: 'Custom event' } });
Then, in GTM i have trigger for this Custom event (event name is the same everywhere) and tag which sends event to Google Analytics. Then in GA i marked that event as conversion, but when i trigger that event on website it shows up as regular event but not as conversion.
This works perfect for every other event but not for this one. I tried to rename event and mark new event as conversion but it didn't help.
Could anyone by any chance know the reason why it doesn't work as expected only for this event?
I am not sure follow the actual issue you are having but you're missing a ' in your code after the event name
this
GTM.dataLayer({ dataLayer: { event: 'Custom event } });
should change to
GTM.dataLayer({ dataLayer: { event: 'Custom event' } });
Otherwise, are you saying that you are specifically using the string "Custom event" as the event parameter value? Perhaps that is a reserved value in the system used for something else, but it seems unlikely.

Targeting keydown events to an angularJS custom directive

I am working on a problem wherein I am required to pick-up keydown events (specifically ctrl+p and then point to a print function which already exists) on a certain custom directive and under certain conditions (a certain tab should be selected). My current approach is to bind the keydown event on the document itself, broadcast it and then listen to it in the required custom directive. Following is the code I have placed in the app.run.. block -
angular.element($document).on('keydown', function(evt) {
if(evt.ctrlKey && evt.key==='p'){
$rootScope.$broadcast('printOnKeyPress');
}
});
This part is working as expected, the problem arises when I try to handle it in the required controller of the custom directive as follows:
$scope.$on('printOnKeyPress', function() {
//point to existing print function
}
This is where the problem arises. It goes into the print function but still the output is incorrect. I am missing something and I can't figure out what.
Also, this is not a good approach but I have searched and am unable to find a possible solution to just bind the keydown event on that custom directive itself (the component only appears if a document is selected).
(ng-keydown won't also work here)
Any help is appreciated!
You could put it in the directive and use the scope destroy event to remove the listener.
Within directive link function:
function keyHandler(evt) {
if (evt.ctrlKey && evt.key === 'p') {
// do your print
}
}
angular.element($document).on('keydown', keyHandler);
scope.$on('$destroy', function() {
angular.element($document).off('keydown', keyHandler);
});

How to know the source of the event in Angularjs

I am looking for a way to know the source of the event in angularjs routing. Here is the scenario I am trying to solve. When url changes I want to know whether the change was caused by a browser back button or not. I thought I can do like this
$scope.$on('$routeUpdate', function (event) {
//if source is back button do this stuff
// if not do this
});
But the event object doesn't have a source information. Did I miss something here? Is there a better way to do it?
Instead of $routeUpdate use '$locationChangeStart'
Here's the discussion about it from the angularjs guys: https://github.com/angular/angular.js/issues/2109
Example:
$scope.$on('$locationChangeStart', function(event) {
if ($scope.form.$invalid) {
event.preventDefault();
}
});

fire angular datatables page event

I need to load data from the server on page change event of datatables.I am using angular-datatables.min.js. but can not seem to latch on to the page.dt event of the datables through angular scope. Please help me on this.
Not sure if you got it working- but this is what I just had to do. Might not be the most elegant but I am able to catch the colum-sizing.dt event:
$scope.$on('event:dataTableLoaded', function (event, loadedDT) {
// loadedDT.DataTable is the DataTable API instance
// loadedDT.dataTable is the jQuery Object
loadedDT.DataTable.on('column-sizing.dt', function(e, settings) {
console.log('WOOOHOOOO');
});
});
I catch the angular-datatables event that gets fired when a data table is loaded and then I bind the data tables events on it there.

EXT JS - adding a listener on any element added to a container

HI,
I have a ExtJS parent 'container' type, whereas i need to add a 'contextmenu' listener to any element that is added to this parent container, via Drag/Drop.
Can someone guide me as to the best way to do this?
I have tried this below but can't get the function to fire.
myContainer.on('added', function(obj1,obj2,index){
alert('added');
});
this may not be the 'best practice' to do it this way anyway...?
thanks for the help !
You're using the wrong event... The added event gets fired when (using your example) myContainer is added to some other container. What you'll need is the add event that fires, when an item is added to myContainer:
myContainer.on('add', function(container, component, index) {
component.on('contextmenu', function() {
});
});

Resources