this.up() is not function EXTJS











up vote
0
down vote

favorite
1












I want submit my data to server ffrom controller.
It is particullart controller code:



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 debuger i see next error: Uncaught TypeError: this.up is not a function. What is wrong? This 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
    yesterday










  • if you don't mind please show how it should look like
    – Tyomik_mnemonic
    yesterday






  • 1




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















up vote
0
down vote

favorite
1












I want submit my data to server ffrom controller.
It is particullart controller code:



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 debuger i see next error: Uncaught TypeError: this.up is not a function. What is wrong? This 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
    yesterday










  • if you don't mind please show how it should look like
    – Tyomik_mnemonic
    yesterday






  • 1




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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I want submit my data to server ffrom controller.
It is particullart controller code:



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 debuger i see next error: Uncaught TypeError: this.up is not a function. What is wrong? This good way to get and submit data?



P.S. url for POST request define in code of form










share|improve this question













I want submit my data to server ffrom controller.
It is particullart controller code:



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 debuger i see next error: Uncaught TypeError: this.up is not a function. What is wrong? This 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










asked yesterday









Tyomik_mnemonic

346




346












  • make that handler function an arrow function instead, to preserve the this of the surrounding scope
    – Robin Zigmond
    yesterday










  • if you don't mind please show how it should look like
    – Tyomik_mnemonic
    yesterday






  • 1




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


















  • make that handler function an arrow function instead, to preserve the this of the surrounding scope
    – Robin Zigmond
    yesterday










  • if you don't mind please show how it should look like
    – Tyomik_mnemonic
    yesterday






  • 1




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
















make that handler function an arrow function instead, to preserve the this of the surrounding scope
– Robin Zigmond
yesterday




make that handler function an arrow function instead, to preserve the this of the surrounding scope
– Robin Zigmond
yesterday












if you don't mind please show how it should look like
– Tyomik_mnemonic
yesterday




if you don't mind please show how it should look like
– Tyomik_mnemonic
yesterday




1




1




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




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












1 Answer
1






active

oldest

votes

















up vote
0
down vote














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





















    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
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote














    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

























      up vote
      0
      down vote














      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























        up vote
        0
        down vote










        up vote
        0
        down vote










        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 1 hour ago









        Saurabh Nemade

        953514




        953514






























             

            draft saved


            draft discarded



















































             


            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




















































































            Popular posts from this blog

            How to pass form data using jquery Ajax to insert data in database?

            National Museum of Racing and Hall of Fame

            Guess what letter conforming each word