I'm using开发者_C百科 Facebox, and when I tried to change the content of a tag, it's giving me raw HTML but the rendered form, the code snippet is:
jQuery('#facebox .content').html("<%= escape_javascript(render :partial => 'form')%>");
Anybody has any idea about this? Thanks a lot.
@leomayleomay: By facebox renderer I meant the command that outputs the facebox on screen (there are multiple ways of doing that with facebox)
However, if all you want to do is change the content of the currently showing facebox, then you could call the command jQuery.facebox('some html');
If this doesn't work either, then may be you could give us a link to a page where you are testing this out
This may be old but this is what worked for me
jQuery.facebox('#{escape_javascript(render :partial => 'index') }').html()
the .html() at the end of the line is what actually did it. Without it, it was rendering the raw html... The only problem I'm faced with now is the partial has some javascript but it isn't getting rendered most likely because of the escape_javascript function. I'll keep digging.
That's most likely because HTML is converted into their entities representation thereby giving you raw html output. I am not a ruby guy, but possibly escape_javascript
function does that as the name suggests.
Below example of jQuery code should, for example, append the html rather than output raw html output:
$('#div').html($('#another_div').html());
精彩评论