0
這裏我的情況如下.. 我已經div元素的列表包含patientid和鼠標的另一個信息在我們的計劃,以顯示另一個DIV總患者信息。怎麼能在我的Ruby實現這一軌道上,請幫我...如何寫一個jQuery的一個DIV鼠標懸停更新另一個DIV
這裏我的情況如下.. 我已經div元素的列表包含patientid和鼠標的另一個信息在我們的計劃,以顯示另一個DIV總患者信息。怎麼能在我的Ruby實現這一軌道上,請幫我...如何寫一個jQuery的一個DIV鼠標懸停更新另一個DIV
您可以使用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 %>);