View Full Version : Get a togglefield change event only on tap
mishoboss
4 Jan 2012, 9:50 AM
Hi, I have a togglefield and its value could be set dynamically by setValue(). I need to fire an event on tap, not on every value change. I need the event to fire only when the togglefield is changed by user, not by setValue(). Is there a way to do that?
mishoboss
4 Jan 2012, 10:20 AM
I think I need a "dragend" listener for the toggle thumb, but I can't find it.
mishoboss
5 Jan 2012, 7:49 AM
Anybody any idea? I try different things whole day and still nothing. I can't get the thumb's "dragend" event fired and I can't determine if the "change" event was invoked by setValue() or by thumb drag. Any crazy workaround would be very appreciated :)
fractious
8 Mar 2012, 9:44 AM
Hey mishoboss, did you ever find a solution to this problem? Thanks.
gypsie
31 Mar 2012, 5:55 PM
Hi, I have a togglefield and its value could be set dynamically by setValue(). I need to fire an event on tap, not on every value change. I need the event to fire only when the togglefield is changed by user, not by setValue(). Is there a way to do that?
this is how I did my tap on toggle's thumb in togglefield:
listeners: {
initialize: function () {
var me = this;
var mec = this.getComponent();
var mythumb = this.element.down('.x-thumb');
var mytoggle = this.element.down('.x-toggle');
mythumb.on({
// this improves the ON/OFF effect
drag: {
fn: function () {
console.log('toggle's thumb dragged');
}
},
// this improves the tap action (responds to tap on thumb)
tap: {
fn: function (e) {
console.log('toggle's thumb tapped');
}
}
});
}, // initialize
} // listeners
mishoboss
11 Apr 2012, 6:40 AM
Thanks gypsie,
but you attach listeners only on the thumb. If a user clicks on the green background of the toggle, there's no event. I attached tap and click events to the background, but on Android they are not fired.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.