Does this work with RubyOnRails js requests?

classic Classic list List threaded Threaded
2 messages Options
iso
Reply | Threaded
Open this post in threaded view
|

Does this work with RubyOnRails js requests?

iso
I have a simple login form that returns a rendered partial.  When I click on a link, with the proper rel= settings, I just get directed to the link address.  If I include 'js' in the ext/iframe options, passed in on the Shadowbox.init call, I get the rendered html in a text format.

If I add the player=iframe the request is mapped incorrectly on the server side and I get the whole page returned. If I then add a js extension to the url I get the the html in a text format rendered to the shadowbox screen.

It seems that the issue is in the url mapping that rails does, and shadowbox isn't recognizing the link href format due to the lack of an extension, or shadowbox really is only able to render out html to an iframe (I find this hard to believe).

Is there a way to fix this?

Thanks for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Does this work with RubyOnRails js requests?

Wizzud
I'm sorry but I have no knowledge of RubyOnRails at all, so if some knowledge is required in order to respond to your query then ignore everything below!

(a) quoting riso:
"I have a simple login form that returns a rendered partial."
So the form is submitted - via Ajax presumably? - and some HTML (? I assume that's what "rendered partial" means) is returned and inserted into the DOM somewhere?

(b) quoting riso:
"When I click on a link, with the proper rel= settings, I just get directed to the link address."
Assumption: the 'link' referred to is one of the elements returned in the Ajax call (a) above? And as such has been newly inserted into the DOM? (If not, what's the relevance of (a) above?)

(c) quoting riso:
"If I include 'js' in the ext/iframe options, passed in on the Shadowbox.init call, I get the rendered html in a text format."
So the link in (b) retrieves a javascript file from the server?! Apparently not, because it returns "rendered HTML"! Is there some significance in the use of the term "rendered"? If so, what? The link's (implied) href='[url]filename.js' obviously returns a web page from the server that you want to display in an iframe - otherwise you wouldn't be trying adding 'js' to the ext/iframe options?

(d) quoting riso:
"If I add the player=iframe the request is mapped incorrectly on the server side and I get the whole page returned."
Umm ... I thought that was the point of an iframe - to display a web page? And I don't quite get the relevance of "server side" mapping when it's the client side (browser) that places the requested web page inside the iframe (because that's were it's been told to put it).

(e) quoting riso:
"If I then add a js extension to the url I get the the html in a text format rendered to the shadowbox screen."
Umm ... now I'm confused (again) - doesn't (c) above imply that you already have the 'js' extension on your href's url? If not, what href are you trying to link to?

(f) quoting riso:
"It seems that the issue is in the url mapping that rails does, and shadowbox isn't recognizing the link href format due to the lack of an extension, or shadowbox really is only able to render out html to an iframe (I find this hard to believe)."

I think that you may be trying to use Shadowbox to pull in partial HTML via Ajax?
Shadowbox does not (currently) handle Ajax itself.
It will quite happily handle existing DOM media elements (player:[mediaType]), or load a new page into an iframe (player:iframe), or display a text string as HTML (player:html), or clone the content of an existing DOM element into itself (player:inline).
There is no player:ajax option for retrieving an HTML fragment from the server and displaying it within Shadowbox. It would undoubtedly be extremely useful to have such a facility, but the fact is it doesn't at present.

If (big if!) that is what you need now then you may have to go about in a different way (such as, retrieving and inserting the partial HTML into the DOM - hidden - then getting Shadowbox to display it 'inline' by cloning it - beware use of ids!). Or, develop a player:ajax option yourself? (Or not use Shadowbox, which would be a shame)

One thing to remember - especially wrt (b) above - is that any links brought in via Ajax will not be recognised by Shadowbox (regardless of any rel attribute setting) unless/until you tell Shadowbox about them.

[If you have read through all the above, and are now thinking "He didn't understand a word I wrote!", then I apologise and you are indubitably correct!]
Combine literacy with curiosity and a whole world of information opens up to you