Dan*_*ter 2 extjs sencha-touch
我试图添加一个监听器,但它不会触发
plugins: [{
ptype: 'pullrefresh',
autoPaging: true,
listeners: {
'released': function(plugin,list){
// call the plugins processComplete method to hide the 'loading' indicator
/* your_store.on('load', plugin.processComplete, plugin, {single:true});
// do whatever needs to happen for reload
your_store.load();*/
alert('test');
}
}
}],
Run Code Online (Sandbox Code Playgroud)
我想要做的是有人在刷新事件被触发时拉出列表我们得到用户的纬度和经度并将值加载到商店中.我的问题是商店beforeload:事件没有正确的事件泡沫,因此它可以在它可以获得用户地理位置之前存储json调用.
My Store{
listeners: {
beforeload: function(){
console.log( 'me1' );
//call this to write to location services on device
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log( 'me2' );
Rad.stores.games.getProxy().extraParams.lat = position.coords.latitude;
Rad.stores.games.getProxy().extraParams.long = position.coords.longitude;
});
}
console.log( 'me3' );
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果你看一下控制台,它会显示me1,me3,me2 ....我想让它显示me1,me2,me3.
我真的看过所有的论坛,文档,但我只是需要一些方向来设置监听器和事件冒泡我想.谢谢.
这是你如何做到的:refreshFn
// pull refresh and listupdate plugins
plugins: [
{
ptype: 'pullrefresh',
refreshFn: function(callback, plugin) {
console.log( 'me1' );
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log( 'me2' );
Rad.stores.games.getProxy().extraParams.lat = position.coords.latitude;
Rad.stores.games.getProxy().extraParams.long = position.coords.longitude;
var store = plugin.list.getStore();
store.load(function(records, operation, success) {
callback.call(plugin);
console.log( 'me3' );
});
});
}
}
},
{
ptype: 'listpaging',
autoPaging: false,
}
],
Run Code Online (Sandbox Code Playgroud)
这是商店:
Rad.stores.games = new Ext.data.Store({
id: 'games',
model: 'games',
autoLoad:false,
clearOnPageLoad: false,
proxy: {
type: 'ajax',
url : 'ajax/lc.php',
reader: {
type: 'json',
root: 'results'
}
},
extraParams:{
format:'json'
}
Run Code Online (Sandbox Code Playgroud)
});
我发现sencha touch没有分配工作的例子所以我会在找到答案时不断发布自己的问题.
| 归档时间: |
|
| 查看次数: |
5237 次 |
| 最近记录: |