javascript - Disable application layout for custom Facebook share button in Rails -
i've implemented custom buttons twitter , facebook sharing in rails app, , have had use javascript below open popups when clicked:
$('.popup, #fbshare').click(function (event) { event.preventdefault(); window.open($(this).attr("href"), "popupwindow", "width=600,height=400,scrollbars=yes"); return false; });
the twitter button works fine facebook share button keeps attempting yield default application layout , giving error message of:
activerecord::recordnotfound in userscontroller#show
couldn't find user id=undefined"
the javascript file named search.js.erb, , i'm trying share link home page, assume need add applicationcontroller, error message makes seem error userscontroller (which route root, i'm not on user page when attempting share).
i've had around , found 2 solutions proffered: 1 add
layout proc{|c| c.request.xhr? ? false : "application" }
to applicationcontroller: doesn't seem work. add
def respond respond_to |format| format.html format.js { render :layout => false } end end
to controller; i've tried adding both application , userscontroller, no luck. i've managed use "render :layout => false" before success unsure how implement in case.
added "popup" class facebook link , removed #fbshare jquery, works, think id confusing rails app thinking user id?
Comments
Post a Comment