Javascript 将值从一个页面传输到另一个页面

Javascript 将值从一个页面传输到另一个页面,javascript,backbone.js,global-variables,Javascript,Backbone.js,Global Variables,我想通过使用主干JS将一个值表单弹出视图传递给父视图 我完成了这样的代码 用于弹出视图 loadPopupGeoBox: function () { var newUserlist = new TripsdetailsModel(); selectModel = newUserlist; var that = this; require(['views/searchlocationek'], function (view) { var view =

我想通过使用主干JS将一个值表单弹出视图传递给父视图

我完成了这样的代码

用于弹出视图

loadPopupGeoBox: function () {         
  var newUserlist = new TripsdetailsModel(); 
  selectModel = newUserlist;
  var that = this;

  require(['views/searchlocationek'], function (view) {
    var view = new view({ model: selectModel}); 
    view.open();
    that.addview = view;
  });

  $('#popup_geocode').fadeIn("slow");
  $("#container").css({ 
    "opacity": "0.3"
  });
},
从弹出页面提交按钮,我们已经做了以下代码

clickClose: function() {
  require(['views/trip'], function (view) {  
    var view1 = new view();
    view1.openfilter(final); 
  }); 

  $('#popup_geocode').fadeOut("slow");
  $("#container").css({ // this is just for style       
    "opacity": "1"
  });
},

如何在父视图中获取“final”的值?

我不确定最佳做法,但一种方法是,将此引用从父视图传递到弹出的
页面,如下所示:

loadPopupGeoBox: function () {         

  // existing code

  var $this = this;

  require(['views/searchlocationek'], function (view) {
    var view = new view({ 
      model: selectModel,
      parent_view: $this
    });   
  });

  // existing code

},
弹出窗口
视图中:

clickClose: function() {
  // storing this reference to be used in the require call back
  var $this = this;
  require(['views/trip'], function (view) {  
    // existing code

    // set the value of the final variable on the parent_view with
    $this.options.parent_view["final_var"] = final;

  }); 

  // existing code
},

执行
clickClose
后,
final
的值将在
parent
视图中使用
this[“final\u var”]

您的表单是什么样子的?不清楚。为什么提交按钮触发关闭功能?预期的行为是什么?我有一个页面,在该页面中有一个文本框和按钮,当我点击按钮时,弹出窗口将使用“loadPopupGeoBox”功能显示。在弹出框中,有一个变量“final”有一个值,例如:100当我使用“clickClose”功能关闭弹出框时,我想用值100填充父文本框