sencha touch - Destroy method in form panel -
i capturing geoposition using cordova api , on success, render current location on google map.
when first get_position using render form follows:
var geo_panel = new ext.form.panel({ usecurrentlocation: true, fullscreen: true, layout: 'fit', items: obj });
where obj toolbar defined as
toolbar = ext.create('ext.toolbar', { docked: 'top', alias : 'widget.geolocationtoolbar', ui: 'light', defaults: { iconmask: true }, items: [ { xtype: 'button', ui: 'back', text: 'back', // destroy form.panel overlay , return tree store view handler: function() { geo_panel.destroy(); } }, { xtype: 'button', itemid: 'stopwatch', text: 'stopwatch', iconcls: 'arrow_right', iconmask: true, handler: function() { evaluateit.utils.utilityservice.clear_watch(); } }, { xtype: 'selectfield', itemid: 'accuracy', autoselect: false, placeholder: 'accuracy', options: [ {text: ''}, {text: 'high', value: 5}, {text: 'med high', value: 10}, {text: 'medium', value: 15}, {text: 'med low', value: 20}, {text: 'low', value: 66} ], listeners: { change: function(field, value) { if (value instanceof ext.data.model) { value = value.get(field.getvaluefield()); } console.log(value); // set accuracy config variable evaluateit.config.accuracy = value; } } }, { iconcls: 'home', handler: function() { google_map.getmap().panto(position); } } ] });
this renders fine in form panel.
my onsuccess method passes argument add google_map geo_panel form panel. have tried geo_panel.add(toolbar, google_map), works, issue of when hit "back" button in toolbar above:
{ xtype: 'button', ui: 'back', text: 'back', // destroy form.panel overlay , return tree store view handler: function() { geo_panel.destroy(); } },
i have click twice: first time destroys google_map , second destroys toolbar. undesirable behavior. i've tried destroying each of items in geo_panel, other weird things. acting there multiple instances of geo_panel. ideas?
i figured out: creating 2 instances of geo_panel. refactored code , works desired.
Comments
Post a Comment