HI
I have a .js.erb file, like:
(1) $(''#ajax-content'').html(" here to beigin <br/>
")
(2) $(''#ajax-content'').append("
<%= escape_javascript(
render :partial => ''ajaxnewmsg'', :locals
=>
{ :privatemsg => @privatemsg }
).html_safe
%>
")
(3) $(''#ajax-content'').append(" yes finished!")
if without (2) , (1),(3) can show the on the web page with firefox.
But if there is (2), nothing will show on the ajax-content. I
attached the ajax response from firebug at the end. ( anything wrong
with that response?)
The question is: what is the best practice to show the complicated
html ( render result) in .js.erb template? ( render :partial
=> ''ajaxnewmsg'', :locals => { :privatemsg =>
@privatemsg } should be
perfect legal in rails/ruby )
why it is not working? How could I debug it?
##the response see from firebug
$(''#ajax-content'').html(" yes I am here to beigin
<br/> ")
$(''#ajax-content'').append("<a
href=\"/privatemsgs?locale=en\">Back to
Inbox<\/a>")
$(''#ajax-content'').append("
<a href=\"/privatemsgs?locale=en\">Back to
Inbox<\/a><br/> \n<h3>
\nSend message to :\n<\/h3>\n\n<form accept-charset=\"UTF-8\"
action\"/privatemsgs/createmsg?locale=en\"
method=\"post\"><div
style\"margin:0;padding:0;display:inline\"><input
name=\"utf8\" type\"hidden\"
value=\"✓\" /><input
name=\"authenticity_token\"
type=\"hidden\"
value=\"cAmImbh6beNCdYm/OIXo8EFLasELwvaewpw4QvO45TY\"
/><\/div>\n \n\n\n<!--[form:privatemsg]-->\n<b>Name
<\/b> <br/>
\n <style type="text/css">
div.auto_complete {\n width: 350px;\n background:
#fff;\n }\n div.auto_complete ul {\n border:1px
solid #888;\n margin:0;\n padding:0;\n
width:100%;\n list-style-type:none;\n }\n
div.auto_complete ul li {\n margin:0;\n padding:3px;
\n }\n div.auto_complete ul li.selected {\n
background-color: #ffb;\n }\n div.auto_complete ul
strong.highlight {\n color: #800; \n margin:
0;\n padding:0;\n }\n</style>\n <input
id="model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd"
name="privatemsg[member_id]" type="hidden"
/>
\n <input
id="model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd"
name="member[name]"
onchange="window.setTimeout(function () {this.value
this.model_auto_completer_cache}.bind(this), 200)"
onfocus="if (this.model_auto_completer_cache == undefined)
{this.model_auto_completer_cache = this.value}"
onkeypress="return event.keyCode == Event.KEY_RETURN ? false :
true" type="text" />\n <div
class="auto_complete"
id="model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_complete"></
div>\n <script
type="text/javascript">\n//<!
[CDATA[\nvar
model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_completer
= new
Ajax.Autocompleter(\''model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd
\'',
\''model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_complete
\'',
\''/privatemsgs/auto_complete_belongs_to_for_privatemsg_member_name?
locale=en\'', {afterUpdateElement: function(element, value) { var
model_id = /(\\d+)$/.exec(value.id)[1]; $
("model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd").value
= model_id; element.model_auto_completer_cache = element.value;
(Prototype.emptyFunction)(element, value, $
("model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd"),
model_id); } , parameters:\''authenticity_token=\'' +
encodeURIComponent(\''cAmImbh6beNCdYm/OIXo8EFLasELwvaewpw4QvO45TY=\'')})
\n//]]>\n</script>\n\n<br/>\n\n<input
id\"privatemsg_from_member_id\"
name=\"privatemsg[from_member_id]\" type\"hidden\"
value=\"349\"
/>\n\n<b>Subject<\/b><br/>\n<input
id\"privatemsg_subject\" name=\"privatemsg[subject]\"
size=\"80\" type\"text\"
/>\n\n<br/>\n\n<b>Message<\/b><br/>\n<textarea
cols=\"59\" id\"privatemsg_message\"
name=\"privatemsg[message]\" rows=\"15\"><\/
textarea>\n<br/>\n\n\n<!--[eoform:privatemsg]-->\n\n <input
name\"commit\" type=\"submit\" value=\"Send\"
/>\n<\/form>
")
$(''#ajax-content'').append(" yes finished!")
thanks.
Sincerely
Min Wang
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.