2013-05-02 85 views

回答

0

您可以使用jQuery鼠標懸停事件發送Ajax請求軌道像

$(".some-div").mouseover(function() { 
    $.ajax({ 
     data: {patientid: some_id}, 
     url: "/your_controllers/your_action" 
    ); 
} 

然後在你的控制器

class YourControllersController < ApplicationController 

    def your_action 
    @model = Model.find(params[:patientid]) 

    respond_to do |format| 
     format.js 
    end 
    end 
end 

然後創建視圖/ your_controllers/your_action.js.erb包含這樣的代碼

$(".expected-to-update-div").html(<%= @model.id %>); 
相關問題