この問題に関連するいくつかの質問を見つけましたが、解決策をコピーしても機能しません。たとえば、jQuery qTip2 の Rails 動的コンテンツ。
処理はコントローラーに到達してコンテンツを生成しますが、ループに陥ります。
$('td.config_info_tip').qtip({
content: {
text: 'Loading',
ajax: {
url: 'config',
data: {
"id": $(this).attr("id")
},
method: 'get'
}
},
style: {
classes: 'ui-tooltip-shadow ui-tooltip-rounded'
}
});
コントローラーで
def config
id = params[:id]
@device = Device.find_by_id(id)
@devicecategory = DeviceCategory.find_by_id(@device.device_category_id)
respond_to do |format|
format.html { render layout: false}
end
end
レンダリングを通過すると、config 関数に戻り、オーバーフローするまでループします。
SystemStackError (stack level too deep):
actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:70
私は別の qtip がうまく動作する同様のことをしています - 私が見ることができる違いは、動作しないものにデータを渡しているということです。もう1つの微妙な点は、機能しないヒントを含むページ自体がjqueryでレンダリングされるため、ヒントのjsコードがページにあり、機能するものは$(document).readyにあります。関数。これがどこで間違っているのかを理解したいと思います。
私はrespond_toを取り出して試してみました
render layout: false
これは機能します:
$('img#priceinfo').qtip({
content: {
text: 'Loading',
ajax: {
url: 'pricing',
type: 'GET'
}
},
style: {
classes: 'ui-tooltip-shadow ui-tooltip-rounded'
}
});
そして、コントローラー
def current
@d = Date.today
# ought to check that we have prices defined
@price = Price.where("effective_from < ?", @d).order("effective_from desc").first
render layout: false
end
誰でも何かアイデアがあります - 何時間も私を困惑させましたか?