How do I use JS in a Sencha Touch view?
Ext.define('project.view.viewexample', {
extend: 'Ext.Panel',
xtype: 'asd',
config: {
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'TITLE!',
Html: '<html>code and also JS?'
}
});
I have htmlcode which includes jscode (within Script-tags). It doesn't seem to work to use in this matter, am I right? I've also tried to use tpl, but it doesn't change anything.
Anyone know how to properly use JS? A somewhat better alternative would be to use it within the controller, but in that case I don't know how to pass the data.
EDIT: I've come somewhat closer to a solution I think. This code below is clearly wrong, but maybe someone can see what I'm doing wrong:
Ext.define('projext.view.viewexample', {
extend: 'Ext.Panel',
xtype: 'gps',
config: {
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'GPS',
tpl: 'Här var det GPS'
},
constructor: function() {
this.getPosition();
},
getPosition: function() {
var geo = Ext.create('Ext.util.Geolocation', {
autoUpdate: false,
listeners: {
locationupdate: function(geo) {
alert('New latitude: ' + geo.getLatitude());
},
locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
if(bTimeout){
alert('Timeout occurred.');
} else {
alert('Error occurred.');
}
}
}
});
geo.updateLocation();
}
});
The html
config needs to be lower-case.
Ext.define('project.view.viewexample', {
extend: 'Ext.Panel',
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'TITLE!',
html: 'define your html'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.