Visualizzazione dei risultati da 1 a 7 su 7

Discussione: JavaScript OO e this.

  1. #1

    JavaScript OO e this.

    Ho il codice:

    codice:
        function deliveryClass(/* Integer */ deliveryId,/* Integer */ customerId)
            {        
            this.updateProductsGrid = function()
                {
                [...]
                }
    
            this.modifyDelivery = function(customer)
                {
                dojo.xhrPost({
                    [...]
                    load: function(data,args)
                        {
                        this.updateProductsGrid();
                        }
                    });
                }        
            }
    Essendo una classe mi aspetterei di usare sempre il selettore this per metodi non statici. Però qui non viene accettato quello in grassetto (e pensandoci il motivo mi è chiaro).

    In suo luogo, il programma accetta ad esempio:

    codice:
        Delivery = new deliveryClass(1,2); 
    
        function deliveryClass(/* Integer */ deliveryId,/* Integer */ customerId)
            {       
            this.updateProductsGrid = function()
                {
                [...]
                }
    
            this.modifyDelivery = function(customer)
                {
                dojo.xhrPost({
                    [...]
                    load: function(data,args)
                        {
                        Delivery.updateProductsGrid();
                        }
                    });
                }
            }
    Domanda: come posso tornare a poter usare il selettore this?
     
    :: Instant WebKiosk, a browser-only Linux operating system ::

  2. #2
     
    :: Instant WebKiosk, a browser-only Linux operating system ::

  3. #3
    Usando hitch si risolve il problema.
     
    :: Instant WebKiosk, a browser-only Linux operating system ::

  4. #4
    Originariamente inviato da emmebì
    Usando hitch si risolve il problema.
    il this si riferisce a dojo.




    Essendo una classe mi aspetterei di usare sempre il selettore this per metodi non statici.
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Intervento incapibile...
     
    :: Instant WebKiosk, a browser-only Linux operating system ::

  6. #6
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  7. #7
    Ehm... avrei già risolto...

    Originariamente inviato da emmebì
    Usando hitch si risolve il problema.
     
    :: Instant WebKiosk, a browser-only Linux operating system ::

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.