Amchart 5: globalpointermove not global - amcharts

How can I set event "on pointermove", not "globalpointermove"?
There is no such event in the documentation
My code:
me.root._rootContainer.events.on("globalpointermove", function (ev) {
console.log(ev)
})

Related

Marionette Layout: trigger event on child view

I have a layout view, with an itemView inside it. I have an event in my item view that triggers a save function. Inside that save function I would like to trigger another event that the layout captures.
So in the code below, in the onClickSave modelSaveSuccess I'd like to trigger a function in the parent layout, I have tried this.methodInParent() but it doesnt work
childView
define(["marionette", "underscore", "text!app/templates/client/form.html", "app/models/client"], function(Marionette, _, Template, Model) {
"use strict"
return Backbone.Marionette.ItemView.extend({
events: {
"submit #saveClient": "onClickSave"
},
onClickSave: function(ev) {
ev.preventDefault()
return this.model.save({}, {
success: function() {
console.log('success - trigger ')
},
error: function(request, error) {
console.log(error.responseText)
}
})
}
})
})
A good way to do it without introducing heavy coupling is to use Marionette's event aggregator as in the linked exemple if you use Backbone.Marionette.application.
// in your view
...
success: function() {
app.vent.trigger('myview:modelsaved');
}
...
// in your layout initialize()
...
app.vent.on('myview:modelsaved', function(){
console.log('model saved in itemView');
});
...
If you don't use Backbone.Marionette.Application you can always create your own Backbone.Wreqr.EventAggregator.

qunit check if event bound to element

/// <reference path="../../../Scripts/myObjectScript.js" />
module("My Test", {
setup: function () {
setUpDOM();
},
teardown: function () {
}
});
test("initialize. page load. setPrimaryWarning bound to change event of primary checkbox", function () {
myObject.Initialize();
var events = $("#Primary").data('events');
equal(1, events.length);
});
function setUpDOM() {
var $primaryCheckBox = "<input data-val='true' data-val-required='Need Primary' id='Primary' name='Primary' type='checkbox' value='false' data-blur-setup='true'>";
$("#qunit-fixture").append($primaryCheckBox);
}
This fails with error Died on test #1 undefined: Unable to get value of the property 'data': object is null or undefined
If I test in the dev tools in chrome $("#Primary").data('events'); will return an Object. Any ideas how I see if an event is bound to an element in qunit or what is wrong with the way I've laid my test out above?

Add after event listener in configuration

I know it is possible to add listeners to events that fire after the event has fired like this:
oDocumentCategories.addAfterListener("activeitemchange", function(oContainer, sValue, oldValue){
//Do stuff here
});
But is it also possible to attach them whilst creating the elements?
Just like this:
var oButton = Ext.create("Ext.Button", {
text: "Button",
listeners: {
tap: function(){
//Tap event here
}
}
});
But only then for an after listener.
Question
Is it possible to attach an after event listener whilst creating an element?
Just like the listeners configuration property but then for an after event listener.
var oButton = Ext.create("Ext.Button", {
text: "Button",
listeners: {
tap: {
fn: function(){
//Tap event here
},
// scope: this,
// options: {single: true}
order: 'after'
}
}
});
Cheers, Oleg

dilemna with jqgrid and ajaxfileupload

I am using jqgrid and ajaxFileUpload.js script in order to pass parameters and files to a php script. The structure of the code is like this:
...
url:url_1.php,
beforeSubmit: function (postdata,formid)
{
$.ajaxFileUpload (
{
url: url_2.php,
...
success:
error:
}),
return[true,""];
},
afterSubmit: function(reponse,postdata)
{
...
return [true,'',''];
}
I have a dilemna:
According to the jqgrid behaviour, url_2.php is called, then url_1.php.
url_2.php handles the data (parameters + file), url_1.php handles nothing.
url_2.php could return an error or message (e.g "already exist") but, the errors are displayed in the form by the aftersubmit event, and this event receives error from url_1.php !!!
I suppose that I am obliged to put the ajaxfileupload in the beforesubmit event !!!
Any ideas to solve this dilemna ?
You can use jquery form plugin and jqGrid dataProxy method instead.
useDataProxy: true,
dataProxy : function (opts, act) {
opts.iframe = true;
var $form = $('#FrmGrid_' + $grid.jqGrid('getGridParam', 'id'));
//Prevent non-file inputs double serialization
var ele = $form.find('INPUT,TEXTAREA,SELECT').not(':file');
ele.each(function () {
$(this).data('name', $(this).attr('name'));
$(this).removeAttr('name');
});
//Send only previously generated data + files
$form.ajaxSubmit(opts);
//Set names back after form being submitted
setTimeout(function () {
ele.each(function () {
$(this).attr('name', $(this).data('name'));
});
}, 200);
};
For example http://jqgrid-php.net file fileUpload class uses this. This is described in How to force dataProxy call in form editing if editurl is set in jqgrid also.

Custom Event For Custom JQuery Plugin

I made this jQuery plugin called removable when you click the objects button it slides up and should trigger a custom event like onDone.
Here's what I did (The codeing format is based on jQuery's http://docs.jquery.com/Plugins/Authoring):
init: function(){
return this.each(function(){
$('a', this).click(function(){
$(this).parent().slideUp(function(){
// Somehow trigger the onDone method
})
});
})
},
onDone: function(){
// Default action
},
and this is what I've done when calling the plugin
$('li').removable({
onDone: function(){
// Overwrite default action
},
})
How can this be done?
If all you need is to call it at the end of the animation, just pass it as the second argument to slideUp or even just call it with $(foo).MyPlugin.onDone() inside the callback function.
otherwise look at trigger and bind jQuery functions - you can use any string you want for those event types so you can trigger and bind a MyPluginDone event
EDIT: based on comments you want something simpler -
As it states in the article you quoted, the best way to provide override-able defaults to options is to have your plugin accept an options object, then to get the combined defaults+overrides you do:
var combinedOpts = $.extend({},defaults,overrides);
and get all the values to use from there...
Try this one.
(function($){
jQuery.fn.extend({
removable: function(options) {
var defaults = {
onDone: function(){alert('default action');}
};
var options = $.extend(defaults, options);
return this.each(function() {
$('a', this).click(function(){
$(this).parent().slideUp(function(){
options.onDone.call();
});
});
});
}
});
})(jQuery);
$('li').removable({
onDone: function(){
alert('Overwrite default action');
},
})

Resources