[CLOSED] How can I set scope in Success function when calling DirectMethod?

  1. #1

    [CLOSED] How can I set scope in Success function when calling DirectMethod?

    I am using a DirectMethod to hit a httphandler and return HTML that I inject into the page. How can I set the scope of the success function?

        getDrillDownMap:function() {
            this.getEl().dom.useMap ='#' +  this.imageMapID;
            Ext.net.DirectMethod.request({
                url: this.imageUrl,
                cleanRequest: true,
                success: function(result, options) {
                    var newMap = Ext.DomHelper.insertHtml('afterEnd', this.getEl().dom, result.html);
                },
                failure: function(result) {
                    debugger;
                },
                scope:this
            });
        
        }
    In the above code, this inside getDrillDownMap refers to an image object. I want to pass that image object as the scope of the success function.
    Last edited by Daniil; Dec 31, 2010 at 6:17 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Try this
    success: function(result, options) {
           var newMap = Ext.DomHelper.insertHtml('afterEnd', this.getEl().dom, result.html);
    }.createDelegate(this),
    or another
    getDrillDownMap:function() {
        this.getEl().dom.useMap ='#' +  this.imageMapID;
        var me = this;
        Ext.net.DirectMethod.request({
            url: this.imageUrl,
            cleanRequest: true,
            success: function(result, options) {
                 // use 'me' variable to get the image
                 var newMap = Ext.DomHelper.insertHtml('afterEnd', this.getEl().dom, result.html);
            },
            failure: function(result) {
                debugger;
            },
            scope:this
        });
     
    }
  3. #3
    Thank you. I used the second option. Is there a reason why setting scope:this is not working? According to ExtJS API:

    scope : Object (Optional)
    The scope in which to execute the callbacks: The "this" object for the callback function. If the url, or params options were specified as functions from which to draw values, then this also serves as the scope for those function calls. Defaults to the browser window.
    And I thought DirectMethod can take the same options as Ext.Ajax
    Last edited by Daniil; Dec 31, 2010 at 6:17 PM. Reason: Used [QUOTE] tags
  4. #4
    Hi,

    Is there a reason why setting scope:this is not working?
    Just it is specific implementation in the DirectEvent class, callbacks are excuted with the following scope
    o.control || window
    We should review that functionality to support the 'scope'
  5. #5
    Finally, we hope to get a scope option working in v3.x.
    https://github.com/extnet/Ext.NET/issues/492
  6. #6
    Quote Originally Posted by Daniil View Post
    Finally, we hope to get a scope option working in v3.x.
    https://github.com/extnet/Ext.NET/issues/492
    Will v3.x be using ExtJS 5.x??
  7. #7
    Yes, it is based on ExtJS 5.
  8. #8
    Finally, we got it fixed for Ext.NET v3.0 beta, revision #6067. it should be released soon.

    Now all handlers of a DirectEvent (Before, After, Success, Failure, Complete) and a DirectMethod (success, failure, complete) are being scoped using the "Scope"/"scope" setting if defined.

Similar Threads

  1. Replies: 0
    Last Post: Jun 13, 2012, 8:47 AM
  2. DirectMethod success and failure not working
    By mtrutledge in forum 1.x Help
    Replies: 3
    Last Post: Mar 14, 2012, 1:08 PM
  3. [CLOSED] Ext.net.DirectEvent.request don't fire my success function
    By emmanuel.sans.domenech in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 06, 2012, 10:32 AM
  4. Success function in calling Direct Method..help!
    By Aleksa007 in forum 1.x Help
    Replies: 2
    Last Post: Jul 26, 2011, 4:36 PM
  5. [CLOSED] Ajaxmethod success function won't fire
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 28, 2009, 3:15 PM

Posting Permissions