在javascript中一次又一次地增加价值

时间:2012-10-08 21:43:37

标签: javascript jquery ruby-on-rails-3 unobtrusive-javascript

在我的JavaScript中,我有三个Linkssecond link已打开取决于所选的first link id。一切正常。但是在选择second link后,如果我想更改first link,则second link仍会针对旧版id打开。如果我想更改first link },所有fields都应根据first link.

进行更改和打开
 var generic_lookup_Enr_Rds_Section2009_selected = function(id, to_s) {
      var question_link = $('#question_picker').attr('href');
      question_link = question_link.replace(/\?+$/, '');
      question_link = question_link + '?columns[enr_rds_section_id]=' + id;
      $('#question_picker').attr('href', question_link);
      $("#modal_popup").dialog("destroy");

  };

  var generic_lookup_Enr_Rds_Question2009_selected = function(id, to_s) {
      var answer_link = $('#answer_picker').attr('href');
      answer_link = answer_link.replace(/\?+$/, '');
      answer_link = answer_link + '?columns[enr_rds_question_id]=' + id;
      $('#answer_picker').attr('href', answer_link);
      $("#modal_popup").dialog("destroy");
  };

HTML

<div class="question">
      <%= f.label :Section %>
      <%= link_to pro_generic_lookup_data_path("Enr::Rds::Section2009", format: :js), data: {remote: true} do %>
        <%= image_tag("Search-icon.gif", border: 0, :alt => "Look up Sections", title: 'Lookup Sections') %>
      <% end %>
 </div>

  <div class="question">
      <%= f.label :Question %>
      <%= link_to pro_generic_lookup_data_path("Enr::Rds::Question2009", format: :js), data: {remote: true}, id: "question_picker" do %>
        <%= image_tag("Search-icon.gif", border: 0, :alt => "Look up Questions", title: 'Lookup Questions', :class => "image_section_search") %>
      <% end %>
 </div>

1 个答案:

答案 0 :(得分:0)

通过Javascript使用级联下拉功能解决它的例子。谢谢你们。