开发者

How do I load pop up box in a JS Rails response?

I have a controller that responds to JS queries:

def show
@event = Event.find(params[:id]) 
respond_to do |format|
format.js
end
end 

My show.js.erb:

$("#modal").html("<%= escape_javascript(render(:partial => @event)) %>");
$('#modal').dialog();

I want to render partial details into pop-up box. In here modal is my hidden div and when I run this code I get some errors and js.erb file run as plain html which having js.erb content.

开发者_JS百科

element.dispatchEvent is not a function

element.tagName is undefined

What is the reason for this? How can I load pop-up box?


I think you might be missing the partial name? Have you tried (assume the partial is called _widget.html.erb):

escape_javascript(render(:partial => 'widget', :locals => {:event => @event}))

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜