1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
    swts is on a distinguished road

      0  

    Default Answered: Doubts Best Way To Do

    Answered: Doubts Best Way To Do


    I wanted to know the best way to do, since I couldn't do It right:
    1. Instead of using some Validation in my Model, It's possible to use my Ajax Request and JSON that brings me the errors and put in the label/container tpl in the config?
    2. For example, I have my Form(not login form) with Field(User) and Button(Confirm), It's better to create new View or Push to bring the data related to User(store, model) like first name and last name. And backwards, in View Profile, should destroy the current View and pop or just call It again?
    3. In my controller, how can I load the data like, age, first name and last name in the Form View Profile depends the Field(User) typed? I tried to use init to load it in my Form but appears in blank, I tried label text and container(tpl).

  2. Point 1:
    Custom validations:

    http://miamicoder.com/2012/sencha-to...ion-functions/

    ...which has a link to model validations too. These tutorials will help you with the understanding needed for your task.

    Point 2:
    No need to create a new view.
    The initial User + Confirm sounds like a job for Ext.Msg.
    Ext.Msg has a callback you can use.

    Code:
    // defined with a function on the form
    var me = this;
    
    
    Ext.Msg.prompt(
        'Welcome!',
        'Please enter your name:',
        function (buttonId, value) {
            if (value !== "") {
            // do AJAX lookup
                Ext.Ajax.request({
                    url: 'user.php',
                    params: {
                        id: value
                    },
                    success: function(response) {
                        var data = response.responseText;
                        me.setValues(data);
                    }
                });
            } else {
                return false;
            }
        },
        me,
        false,
        null,
        {
            autoCapitalize: true,
            placeHolder: 'John Smith'
        }
    );
    Point 3:
    The success callback of the AJAX call above shows the form data population.
    An object of (values / store record / model of values) can be applied to a form using form.setValues(data).

    This page shows some examples to get your head around data, stores, values and just getting things working:
    http://miamicoder.com/2012/sencha-to...nding-records/

  3. #2
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    89
    Answers
    5
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      0  

    Default


    Point 1:
    Custom validations:

    http://miamicoder.com/2012/sencha-to...ion-functions/

    ...which has a link to model validations too. These tutorials will help you with the understanding needed for your task.

    Point 2:
    No need to create a new view.
    The initial User + Confirm sounds like a job for Ext.Msg.
    Ext.Msg has a callback you can use.

    Code:
    // defined with a function on the form
    var me = this;
    
    
    Ext.Msg.prompt(
        'Welcome!',
        'Please enter your name:',
        function (buttonId, value) {
            if (value !== "") {
            // do AJAX lookup
                Ext.Ajax.request({
                    url: 'user.php',
                    params: {
                        id: value
                    },
                    success: function(response) {
                        var data = response.responseText;
                        me.setValues(data);
                    }
                });
            } else {
                return false;
            }
        },
        me,
        false,
        null,
        {
            autoCapitalize: true,
            placeHolder: 'John Smith'
        }
    );
    Point 3:
    The success callback of the AJAX call above shows the form data population.
    An object of (values / store record / model of values) can be applied to a form using form.setValues(data).

    This page shows some examples to get your head around data, stores, values and just getting things working:
    http://miamicoder.com/2012/sencha-to...nding-records/

  4. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
    swts is on a distinguished road

      0  

    Default


    At my point 2, what I did mean is what I should go for transactions between screen, For example, my Form has typically Login type. When It's logged in, I need to create new Profile View. If I'm logged in, I should remove or destroy the View that I'm not using? Same as backwards.
    But after seeing some examples, I quite understand some of it. Thanks!

  5. #4
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    89
    Answers
    5
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      0  

    Default


    Here's a sample series that includes login authentication and redirection based on whether they were navigating the site prior to login (ie redirect them to page they were on), else send them to their profile page:

    Code:
    // doLogin
    var app          = this.getApplication(),
        sessionModel = Ext.create('Mov.model.Session');
    
    
    app.showMask();
    
    
    sessionModel.setData(this.getLoginPanel().getValues());
    
    
    //Send request to the server for validating the username/password
    sessionModel.save({
        'success': this.onSessionValidate, 
        'failure': this.onLoginFailure
        }, this);
    
    
    
    // onSessionValidate
    var response = Ext.JSON.decode( operation._response.responseText ),
        app      = this.getApplication();
    
    
    if (!response.result) {
        return;
    }
    app.doAuthenticate(response, Ext.bind(this.redirectAfterLogin, this));
    
    
    
    // redirectAfterLogin
    var app       = this.getApplication(),
        lastRoute = app.getLastVisitPage();
    
    
    if (Ext.isDefined(lastRoute) && lastRoute !== '' && lastRoute != 'login') {
        app.clearLastVisitPage();
        this.getRoot().pop(3);
        this.redirectTo(lastRoute);
    } else {
        if (app.getLoginType() == 'facebook' && !this.justBackFromFacebook) {
            //Login with Facebook but don't redirect as the user may be currently viewing a different page.
            console.log('Loggedin with FB, but dont redirect');
        } else {
            this.getRoot().pop(3);
            this.redirectTo('profile');
        }
    }
    app.removeMask();

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi