javascript_tag replacing whitespaces w/ ''%20''
Hello,
I have a form that tests if a title has been changed since the page
was loaded and the page has been submitted. If the page title has been
changed then a confirm box will ask if the user wants to have the title
changed. The problem is if the person hits cancel, all white spaces
in the title get replaced w/ ''%20''.
Here''s the code I was using:
<%=javascript_tag( "function confirmSubmit(){ var
page_title_before''#{u @page.title}'';
var page_title_on_submit
escape($(''page_title'').value);
if( page_title_before
!page_title_on_submit ){
var
agree=confirm(''Changing the title of this page will break any links or
bookmarks that refer to it.\\nPress \"OK\" to save with the new title,
or \"Cancel\" to revert to the original title.'');
if(agree){ return true;
}
else{ alert(
''page_title_before-->>'' +
escape(page_title_before) ); $(''page_title'').value =
page_title_before;
return false; }
}
else{ return true; }}") %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hello,
I have a form that tests if a title has been changed since the page was
loaded and the page has been submitted. If the page title has been changed
then a confirm box will ask if the user wants to have the title changed.
The problem is if the person hits cancel, all white spaces in the title get
replaced w/ ''%20''.
Here''s the code I was using:
[code]
<%=javascript_tag( "function confirmSubmit(){ var page_title_before=
''#{u
@page.title}'';
var page_title_on_submit
escape($(''page_title'').value);
if( page_title_before
!page_title_on_submit ){
var
agree=confirm(''Changing
the title of this page will break any links or bookmarks that refer to
it.\\nPress \"OK\" to save with the new title, or \"Cancel\"
to revert to
the original title.'');
if(agree){ return true; }
else{ alert( ''page_title_before-->>'' +
escape(page_title_before) ); $(''page_title'').value =
page_title_before;
return false; }
}
else{ return true; }}") %>
[/code]
--
View this message in context:
http://www.nabble.com/javascript_tag-replacing-whitespaces-w--%27-20%27-tf3948381.html#a11201320
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---