-
14 Mar 2012 2:06 PM #1
Unanswered: Javascript var scoping in Migration to 2.x
Unanswered: Javascript var scoping in Migration to 2.x
I have an application working in Sencha Touch 1.x and I'm looking migrate it to Sencha Touch 2.x. I've followed the guide and done with the basic part. However, I found this problem in console:
This function is called from index.js asCode:TypeError: 'undefined' is not a function (evaluating 'User.getLoginFormBase(loginHandlerCB)') index.js 119
while this function is defined in file mobile,js asCode:Ext.setup({ //... onReady: function() {loginHandlerCB = function(ele, eve) {//... }; registerLoginHandler = function() { loginFormBase = User.getLoginFormBase(loginHandlerCB);};} });
It used to work fine in Sencha Touch 1.x. So in ST2, is there a basic difference in javascript variable scoping or in starting the application using Ext.setup() and putting everything inside it?Code:var User = { getLoginFormBase: function(loginCB) { //... }
-
15 Mar 2012 4:58 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3102
I'd create a utility class:
Code:Ext.define('User', { singelton : true, getLoginFormBase: function(loginCB) {...} });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote