Javascript 如何在调用模型获取时在主干中创建加载屏幕?

Javascript 如何在调用模型获取时在主干中创建加载屏幕?,javascript,backbone.js,Javascript,Backbone.js,我正在尝试设置加载屏幕,而this.model.fetch({})正在发生,不确定如何调用它。。。这是我当前尝试的事件触发器,但它没有触发 search: function (e) { console.log('searching...'); var eventL = this.vent; e.preventDefault(); var that; that = this.model; //post instance to

我正在尝试设置加载屏幕,而this.model.fetch({})正在发生,不确定如何调用它。。。这是我当前尝试的事件触发器,但它没有触发

search: function (e) {
      console.log('searching...');
      var eventL = this.vent;
      e.preventDefault();
      var that;

      that = this.model;
      //post instance to the server with the following input fields
      this.model.fetch(
        {data: {
          channel: $('#channel').val(),
          week: $('#week').val(),
          year: $('#year').val(),
          filter: $('#filter').val()
        },
      attack: this.options.vent.trigger('ok', data),
      success: $.proxy(this.storeMusic, this )
    });
    },

如果可能的话,我也想将数据发回,以便将值包括在搜索屏幕中。

如果您试图将状态保存回服务器,您需要的是
save
方法,而不是
fetch
save
方法(以及
fetch
)接受成功回调(请参阅),您可以使用该回调触发隐藏加载屏幕的事件

大概是这样的:

var self = this;

// About to save, fire event to indicate loading screen should be displayed
this.options.vent.trigger('saveStarted');

this.model.save({
  channel: $('#channel').val(),
  week: $('#week').val(),
  year: $('#year').val(),
  filter: $('#filter').val()
},
{
  success: function(model /*, response, options */) {
    // Save completed, fire event to indicate loading screen should be hidden
    // The model is available as the first parameter of the callback
    self.options.vent.trigger('saveCompleted', model);
  }
});

我基本上明白了,我正在调用一个函数,用加载替换屏幕,当另一个页面准备加载时,它会更改页面