this.up() is not function EXTJS











up vote
0
down vote

favorite
1












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










share|improve this question
























  • 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






  • 1




    instead of handler: function() {...} do handler: () => {...}. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
    – Robin Zigmond
    Nov 8 at 9:17















up vote
0
down vote

favorite
1












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










share|improve this question
























  • 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






  • 1




    instead of handler: function() {...} do handler: () => {...}. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
    – Robin Zigmond
    Nov 8 at 9:17













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 13:53









Sandy

1,4391620




1,4391620










asked Nov 8 at 8:59









Tyomik_mnemonic

328




328












  • 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






  • 1




    instead of handler: function() {...} do handler: () => {...}. 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










  • if you don't mind please show how it should look like
    – Tyomik_mnemonic
    Nov 8 at 9:14






  • 1




    instead of handler: function() {...} do handler: () => {...}. 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












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.






share|improve this answer

















  • 1




    i have understood how it work when i have red your answer . Gracio!
    – Tyomik_mnemonic
    Nov 12 at 11:10











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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.






share|improve this answer

















  • 1




    i have understood how it work when i have red your answer . Gracio!
    – Tyomik_mnemonic
    Nov 12 at 11:10















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.






share|improve this answer

















  • 1




    i have understood how it work when i have red your answer . Gracio!
    – Tyomik_mnemonic
    Nov 12 at 11:10













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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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














  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()