this.up() is not function EXTJS
up vote
0
down vote
favorite
I want to submit my data to server from controller.
Code is as follows:
renterForms: function() {
var items3 = [{
xtype:'foresto-renterdata',
scrollable: true,
scope: this,
renderTo: 'mainPart',
handler: function() {
this.action3.hide();
}
},{
text: 'Submit',
ui: 'confirm',
scope: this,
handler: function() {
var form = this.up('foresto-rentertype');
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
} else { /
Ext.Msg.alert('Error', 'Please correct form errors.')
}
}
in chrome debugger, I see next error:
Uncaught TypeError: this.up is not a function.
What is wrong? Is this a good way to get and submit data?
P.S. url for POST request define in code of form
javascript extjs web-applications extjs4 sencha-touch
add a comment |
up vote
0
down vote
favorite
I want to submit my data to server from controller.
Code is as follows:
renterForms: function() {
var items3 = [{
xtype:'foresto-renterdata',
scrollable: true,
scope: this,
renderTo: 'mainPart',
handler: function() {
this.action3.hide();
}
},{
text: 'Submit',
ui: 'confirm',
scope: this,
handler: function() {
var form = this.up('foresto-rentertype');
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
} else { /
Ext.Msg.alert('Error', 'Please correct form errors.')
}
}
in chrome debugger, I see next error:
Uncaught TypeError: this.up is not a function.
What is wrong? Is this a good way to get and submit data?
P.S. url for POST request define in code of form
javascript extjs web-applications extjs4 sencha-touch
make thathandler
function an arrow function instead, to preserve thethis
of the surrounding scope
– Robin Zigmond
Nov 8 at 9:06
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
1
instead ofhandler: function() {...}
dohandler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– Robin Zigmond
Nov 8 at 9:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to submit my data to server from controller.
Code is as follows:
renterForms: function() {
var items3 = [{
xtype:'foresto-renterdata',
scrollable: true,
scope: this,
renderTo: 'mainPart',
handler: function() {
this.action3.hide();
}
},{
text: 'Submit',
ui: 'confirm',
scope: this,
handler: function() {
var form = this.up('foresto-rentertype');
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
} else { /
Ext.Msg.alert('Error', 'Please correct form errors.')
}
}
in chrome debugger, I see next error:
Uncaught TypeError: this.up is not a function.
What is wrong? Is this a good way to get and submit data?
P.S. url for POST request define in code of form
javascript extjs web-applications extjs4 sencha-touch
I want to submit my data to server from controller.
Code is as follows:
renterForms: function() {
var items3 = [{
xtype:'foresto-renterdata',
scrollable: true,
scope: this,
renderTo: 'mainPart',
handler: function() {
this.action3.hide();
}
},{
text: 'Submit',
ui: 'confirm',
scope: this,
handler: function() {
var form = this.up('foresto-rentertype');
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
} else { /
Ext.Msg.alert('Error', 'Please correct form errors.')
}
}
in chrome debugger, I see next error:
Uncaught TypeError: this.up is not a function.
What is wrong? Is this a good way to get and submit data?
P.S. url for POST request define in code of form
javascript extjs web-applications extjs4 sencha-touch
javascript extjs web-applications extjs4 sencha-touch
edited Nov 9 at 13:53
Sandy
1,4391620
1,4391620
asked Nov 8 at 8:59
Tyomik_mnemonic
328
328
make thathandler
function an arrow function instead, to preserve thethis
of the surrounding scope
– Robin Zigmond
Nov 8 at 9:06
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
1
instead ofhandler: function() {...}
dohandler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– Robin Zigmond
Nov 8 at 9:17
add a comment |
make thathandler
function an arrow function instead, to preserve thethis
of the surrounding scope
– Robin Zigmond
Nov 8 at 9:06
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
1
instead ofhandler: function() {...}
dohandler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– Robin Zigmond
Nov 8 at 9:17
make that
handler
function an arrow function instead, to preserve the this
of the surrounding scope– Robin Zigmond
Nov 8 at 9:06
make that
handler
function an arrow function instead, to preserve the this
of the surrounding scope– Robin Zigmond
Nov 8 at 9:06
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
1
1
instead of
handler: function() {...}
do handler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…– Robin Zigmond
Nov 8 at 9:17
instead of
handler: function() {...}
do handler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…– Robin Zigmond
Nov 8 at 9:17
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
scope: this
this is the actual issue which is messing up with scope inside handler function. Remove it and it will resolve the up function.
You can see the behavior with scope with following example fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/2nhv
When "scope: this" is defined, then scope while building the component will be used and injected inside the handler function. It is equivalent to explicitly writing handlerFn.bind(this) which simply binds the different scope and returns a new function.
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
scope: this
this is the actual issue which is messing up with scope inside handler function. Remove it and it will resolve the up function.
You can see the behavior with scope with following example fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/2nhv
When "scope: this" is defined, then scope while building the component will be used and injected inside the handler function. It is equivalent to explicitly writing handlerFn.bind(this) which simply binds the different scope and returns a new function.
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
add a comment |
up vote
1
down vote
accepted
scope: this
this is the actual issue which is messing up with scope inside handler function. Remove it and it will resolve the up function.
You can see the behavior with scope with following example fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/2nhv
When "scope: this" is defined, then scope while building the component will be used and injected inside the handler function. It is equivalent to explicitly writing handlerFn.bind(this) which simply binds the different scope and returns a new function.
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
scope: this
this is the actual issue which is messing up with scope inside handler function. Remove it and it will resolve the up function.
You can see the behavior with scope with following example fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/2nhv
When "scope: this" is defined, then scope while building the component will be used and injected inside the handler function. It is equivalent to explicitly writing handlerFn.bind(this) which simply binds the different scope and returns a new function.
scope: this
this is the actual issue which is messing up with scope inside handler function. Remove it and it will resolve the up function.
You can see the behavior with scope with following example fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/2nhv
When "scope: this" is defined, then scope while building the component will be used and injected inside the handler function. It is equivalent to explicitly writing handlerFn.bind(this) which simply binds the different scope and returns a new function.
answered Nov 9 at 9:45
Saurabh Nemade
1,108515
1,108515
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
add a comment |
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
1
1
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
i have understood how it work when i have red your answer . Gracio!
– Tyomik_mnemonic
Nov 12 at 11:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204369%2fthis-up-is-not-function-extjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
make that
handler
function an arrow function instead, to preserve thethis
of the surrounding scope– Robin Zigmond
Nov 8 at 9:06
if you don't mind please show how it should look like
– Tyomik_mnemonic
Nov 8 at 9:14
1
instead of
handler: function() {...}
dohandler: () => {...}
. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…– Robin Zigmond
Nov 8 at 9:17