2012-02-16 6 views
0

하나의 양식에서 두 개의 제출 버튼을 사용할 수있는 방법은 다른 작업에 제출하는 방법입니까?레일즈에서 form_for 내에 두 개의 제출 버튼을 두는 방법은 다른 액션에 제출 하시겠습니까?

는 내가 처음이 question을보고, 라이언 베이츠는 서로 다른 행동 양식을 제출 submit_to_remote 방법을 사용하여 제안이 Railscast의 끝으로이에 대한 답변 중 하나 (오히려 세) railscast의 링크를 따라 갔다. 내가이 submit_to_remote 메소드를 documenation에서 찾을 수 없습니다 (레일즈 3.1을 사용하고 있습니다). 다른 제출 버튼을 다른 작업에 제출하는 방법이 있습니까?

+0

한 단어 ... jQuery – drhenner

답변

0
var Widgets = window.Widgets || { }; 
Widgets.orders = { 
    initialize  : function() { 
     jQuery('#sumbit1').live('click', function(){ 
      Widgets.orders.submitOne(); 
     }); 
     jQuery('#sumbit2').live('click', function(){ 
      Widgets.orders.submitTwo(); 
     }); 
    }, 

    submitOne :function(num) { 
     jQuery.ajax({ 
      type : "POST", 
      url: "/widgets/orders" , 
      data: jQuery('#order_form').serialize(), 
      success: function(htmlText){ 
      if (htmlText.status > 399) { 
       alert('OH NO!!! Something went wrong!!'); 
      } else { 
       jQuery('#orders').html(htmlText); 
      } 
      }, 
      dataType: 'html' 
     }); 
    }, 
    submitTwo :function(num) { 
     jQuery.ajax({ 
      type : "POST", 
      url: "/blah/orders" , 
      data: jQuery('#order_form').serialize(), 
      success: function(htmlText){ 
      if (htmlText.status > 399) { 
       alert('OH NO!!! Something went wrong!!'); 
      } else { 
       jQuery('#orders').html(htmlText); 
      } 
      }, 
      dataType: 'html' 
     }); 
    } 

// Start it up 
jQuery(function() { 
    Widgets.orders.initialize(); 
}); 

}; 
관련 문제