I tried to use an event that is triggered when the current window is maximized, however I can't seem to get the event triggerd.
I tried the following:
var appWindow = Ti.UI.currentWindow();
appWindow.addEventListener('maximized', function(){
alert('maximized...');
});
and:
Ti.UI.UserWindow.maximized(function() {
alert('test2');
});
and:
Ti.UI.currentWindow.maximized( function() {
alert('test');
});
Does anyone know how to use this event: http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.UI.UserWindow-event-maximized ?
The following should work:
var appWindow = Ti.UI.getCurrentWindow();
appWindow.addEventListener(Ti.MAXIMIZED, function(){
alert('maximized');
});
Related
How do I attach a handler to the navigation buttons in FullCalendar v4? There is nothing specified in the official documentation.
One way to get what you need is to hide the default prev and next buttons and replace with your own custom buttons, for which there are click callbacks.
Please see https://codepen.io/ormasoftchile/pen/NVJeez for a working example.
customButtons: {
customprev: {
text: '<',
click: function() {
alert('clicked custom button 1!');
calendar.prev();
}
},
customnext: {
text: '>',
click: function() {
alert('clicked custom button 2!');
calendar.next();
}
}
}
Regards, Cristian
The only build-in method is the events: fn () callback. From the docs
FullCalendar will call this function whenever it needs new event data.
This is triggered when the user clicks prev/next or switches views.
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid' ],
defaultView: 'dayGridMonth',
events: function (info) {
console.log(info);
}
});
calendar.render();
});
I am using the following path to logout in iron-router
Router.route('/logout',{
name: 'logout',
onBeforeAction: function(){
Meteor.logout(function(err){
console.log('logging out' + Meteor.userId());
Router.go('/');
});
}
});
which is used in many places in my app when it is triggered by:
Template._loginButtonsLoggedInDropdown.events({
'click #login-buttons-logout': function (event) {
event.preventDefault();
Router.go('/logout');
}
});
It works fine everywhere but it fails to logout from one template;actually is logs out but after 20secs or so; this specific template has 3 reactive template's vars and 2 subscriptions defined in .onCreated function.
I am looking for any hints why it is so slow and if i should close the template or subscriptions in other way? or any other reason why it logs out so slowly..
version without routers works the same (meaning logout still takes 20sec)
'click #login-buttons-logout': function (event) {
event.preventDefault();
Meteor.logout(function(err){
console.log('logging out' + Meteor.userId());
Router.go('/');
});
}
There is no reason to use a route for the logout. Just change your event handler as follows:
Template._loginButtonsLoggedInDropdown.events({
'click #login-buttons-logout': function (event) {
event.preventDefault();
Meteor.logout(function() {
Router.go('/');
}
}
});
And get rid of the route 'logout'.
the problem was my subscription although I do not fully understand why.
My code was:
Template.observedQuestions.onCreated(function(){
var self = this;
self.autorun(function(comp){
self.subscribe('observedQuestionsFeed');
});
});
which i then changed to:
Template.observedQuestions.onCreated(function(){
computation = Tracker.autorun(function(thisComp){
status = Session.get('loggingOut');
console.log('tracker started ' + status);
mySubscription = self.subscribe('observedQuestionsFeed');
if (status){
thisComp.stop();
}
});
});
where I do stop the computation manually and it works.
thank you all for your help.
How do I add mobile swipe left/right events in Meteor?
I've tried...
Template.NAME.events({
'swipeleft': function(){ //DO SOMETHING }
})
I've also tried using chriswessels/meteor-hammer package,
Template.NAME.gestures({
'swipeleft .img-contain': function(){
alert("test")
},
'tap': function(){
alert("test")
},
})
Neither of those methods worked.
Did you try the hammer:hammer package?
Seems like work pretty good.
You can configurate like this.
Template.NAME.rendered = function(){
$('body').hammer({
drag_min_distance:1,
swipe_velocity:0.1
});
};
And this Events
Template.NAME.events({
'swipeleft #hammerDiv': function(e, t) {
e.preventDefault();
//Do cool stuff here
},
'swiperight #hammerDiv': function(e, t) {
e.preventDefault();
//Do cool stuff here
}
});
I'm trying to detect when the user hits "refresh" from my app to load some data.
I have this:
var refresh = function() {
alert('refresh');
};
var vm = {
refresh: refresh,
data: ko.observable()
};
However I never get the alert in my browser, and a breakpoint set at the opening of the function does not get hit when I refresh the page from this view. How can I properly use the refresh function?
I would suggest hooking into the canDeactivate method in your view model.
var refresh = function() {
alert('refresh');
};
var canDeactivate = function(isClose){
if (isClose)
{
refresh();
return false;
}
else return true;
};
var vm = {
data: ko.observable(),
canDeactivate: canDeactivate
};
I'm trying to simply return what I request in PHP to JSON.
My problem is that each Stock is not yet completed.
Indeed, it is the "render" but "this.collection.models" is not yet completed because the request is not yet finished.
What should I do to correct this problem, wait until the request is finished so that the loop is done correctly.
Thank you in advance
var Article = Backbone.Model.extend({});
var Articles = Backbone.Collection.extend({
model:Article,
url: function() {
return _BASE_URL+'/sync/getLastArticles';
},
initialize:function () {
this.fetch();
}
});
var ArticlesView = Backbone.View.extend({
template:$('#articles').html(),
initialize:function () {
this.collection = new Articles();
this.render();
},
render:function () {
console.log(this.collection);
var that = this;
_.each(this.collection.models, function (item) {
console.log(item);
}, this);
},
renderArticle:function () {
;
}
});
You render before the fetch is done. What you want to do, is to wait for the fetch to complete and then render. Now how would you get notification of when the fetch is done? You have 2 options:
The success function (Not recommended by me)
// ArticlesView
initialize: function() {
_.bindAll(this); // Don't forget to BIND
this.collection = new Articles();
this.collection.fetch({
success: this.render
});
}
Now when the fetch has been successful, render is called. This however can cause scoping problems and Backbone.js offers a much nicer alternative to callback functions: events.
Event callback (prefer this)
// ArticlesView
initialize: function() {
_.bindAll(this);
this.collection = new Articles();
this.collection.on('reset', this.render); // bind the reset event to render
this.collection.fetch();
}