Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Aynchronous Routing in ember js

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 718
    Comment on it

    It is not possible to have two db queries in model hook of ember js router. You can either create two router files- one for fetching the new records from database and the another one for fetching record.


    That is not a good approach to create two route files for two similar actions.

     

    If you are stucked in such a case you can follow my approach:-

     

    I used Ember.RSVP and created to json elements, one for creating a record and the another one for fetching the records from clubsetting collection.
     

    import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
    import Config from 'ghost-admin/config';
    
    var self,
        error = "",
        success = "",
        validator = Config.settings;
    export default AuthenticatedRoute.extend({
        titleToken: 'Setting',
    
        model() {
            return Ember.RSVP.hash({
              settingModel: this.store.createRecord('clubsetting'),
              settings: this.store.queryRecord('clubsetting', {}).then((record) => {
                    return record;
                }),
            });
    
        },
        renderTemplate(controller, model) {
            this.render('club-configuration/edit', {
                controller,
                model: model.settings
            });
        },
    
        setupController: function(controller, model) {
            this._super(...arguments);
            controller.set('model', model.settingModel);
            controller.set('flagDelete', true);
            controller.set('error', error);
            controller.set('success', success);
        },
    });
    
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: