Rails - 打开模型时在iFrame中提交表单

时间:2016-09-02 13:14:21

标签: javascript jquery ruby-on-rails forms iframe

我正在尝试使用Yodlee的API,该API需要提交表单并使用iFrame。

当用户加载模型时,如何自动提交表单并在iFrame中加载?这是我的初始(非工作)代码:

%myModal_fastlink.modal
  %label{:for => "modal-1"}
    %li Add Portfolio
  %input#modal-1.modal-state{:type => "checkbox"}/
  .modal-fade-screen
    .modal-inner
      .modal-close{:for => "modal-1"}
      %iframe{:height => "100%", :name => "an_iframe", :src => "https://node.developer.yodlee.com/authenticate/restserver/", :width => "100%"}

%br
%form#rsessionPost{:action => "https://node.developer.yodlee.com/authenticate/restserver/", :method => "POST", target: "an_iframe"}
  %input{name: "app", type: "hidden", value: "10003100"}
  %input{name: "rsession", type: "hidden", value: current_user.yodlee.fastlink.rsession}
  %input{name: "token", type: "hidden", value: current_user.yodlee.fastlink.token}
  %input{name: "redirectReq", type: "hidden", value: "true"}
:javascript
  function launch() {
    $("#myModal_fastlink").modal();
    document.getElementById('rsessionPost').submit();

  }
  $("#myModal_fastlink .btn-close").click(function() {
    $("#myModal_fastlink").modal('toggle');
  });

0 个答案:

没有答案