JavaScript how to render multiple views with their models from ajax calls in backbone render multiple views razor,revit render multiple views,express render

Hey everybody¡ I'm trying to paint a screen with multiple models and associated views in backbone. For this, I have respestive ajax calls to the server, to get data for this vies. First I considered that the solution could be the jquery function $when(ajaxcall1,ajaxcall2)done(function) , but ....

Model1.js

getFById: function (id, context, success, error) {
    this.fetch({
        data: {
            id: id
        }
    }).success(function () {
        success();
    }).error(function () {
        error();
    });
},

parse function data

parse: function (response) {
    response.pedidosEntrega = new App.PedidosbookingCollection(response.datosPedidosbookingDto);
    response.cabeceraBookingDto = response.cabeceraBookingDto;
    return response;
}

model2.js

getFByBooking: function (idBooking, context) {
    return $.ajax({
        async: true,
        context: context,
        cache: false,
        type: 'GET',
        dataType: 'json',
        contentType: 'application/json',
        data: {
            id: idBooking
        },
        url: this.datosPorFUrl,
    });
},

And in my router.js have the calls to render the views.

$.when(this.model.getFById(idBooking, idFactura, this),
       this.collectionF1Candidatas.getFByBooking(idBooking))
    .done(_.bind(function (modelBooking, facturasCandidatas) {
        this.asociarF1BookingExito(facturasCandidatas);
    }, this));

The problem is that the function parse in model 1 is asyncronous whith this multiple call, and dont execute in $when sentence. How can do to sincronyze the ajax calls with parse function?

I know that it isnt the best solution for backbone. Could someone tell me a better solution for implements it in this tecnology?

thanks everyone¡¡

Answer:1

Basically, I want to know if Collections work more like folders (they “physically contain” Models), or playlists (they contain a reference to Models). If they work like folders, is there a convention ...

Basically, I want to know if Collections work more like folders (they “physically contain” Models), or playlists (they contain a reference to Models). If they work like folders, is there a convention ...

I want to assign background image of button in a jquery variable with css.I have written code but it not work. var cmp1; var cmp2; var bg = $("#mq3").css('background-image'); var bg1 = $("#mq6").css(...

I want to assign background image of button in a jquery variable with css.I have written code but it not work. var cmp1; var cmp2; var bg = $("#mq3").css('background-image'); var bg1 = $("#mq6").css(...

  1. assign background image to div
  2. assign background image in html
  3. assign background image to body
  4. assign background image in css
  5. assign background image using css
  6. assign background image using jquery
  7. jquery assign background image
  8. js assign background image

Main module being injected with everything; require('./dashboard'); module.exports = angular.module('college', ['college.dashboard']) .config(function ($stateProvider) { $stateProvider ...

Main module being injected with everything; require('./dashboard'); module.exports = angular.module('college', ['college.dashboard']) .config(function ($stateProvider) { $stateProvider ...

I have the same config blocks for all the angular apps on my site, all in different files. app_1.config([ "$httpProvider", function($httpProvider) { $httpProvider.defaults.headers.common['X-...

I have the same config blocks for all the angular apps on my site, all in different files. app_1.config([ "$httpProvider", function($httpProvider) { $httpProvider.defaults.headers.common['X-...

  1. share same config file