hi,
I have this:
page.hide "transactionpopup"
page.replace_html
@shift.shifttype.name+"_"+@shift.date.strftime(''%d-%m-%Y'')
,calendarday(:shift=>@shift)
@exchangeproposals.each do |ep|
domid=ep.shift.shifttype.name+"_"+ep.shift.date.strftime(''%d-%m-%Y'')
page << "if $(''#{domid}'') {"
page.replace_html domid ,calendarday(:shift=>ep.shift)
page << "}"
end
the problem is with this part:
page << "if $(''#{domid}'') {"
page << "}"
when i use this, my script doesn''t work. , nothing happens and I am not
getting errors at all
I dont have a clue what the problem is.
when i check with firebug i see this response:
try {
Element.hide("transactionpopup");
Element.update("Nacht_30-05-2008", "\u003Cdiv
style=''width:90%''\u003Ejos\u003Cbr\u003E\u003Cimg alt
\"Negotiate\" border=\"0\"
src=\"/images/negotiate.gif?1210763277\"
/\u003E\u003C/div\u003E");
if $(''Nacht_29-05-2008'') {
Element.update("Vroeg_21-05-2008", "\u003Cdiv
style=''width:100%;
height:100%;background:#d0e6f6''\u003Eremco
\u003C/div\u003E");
}
} catch (e) { alert(''RJS error:\n\n'' + e.toString());
alert(''Element.hide(\"transactionpopup\");\nElement
.update(\"Nacht_30-05-2008\", \"\\u003Cdiv
style=\''width:90%\''\\u003Ejos\\u003Cbr\\u003E\\u003Cimg alt
=\\\"Negotiate\\\" border=\\\"0\\\"
src=\\\"/images/negotiate.gif?1210763277\\\" /\\u003E\\u003C/div
\\u003E\");\nif $(\''Nacht_29-05-2008\'')
{\nElement.update(\"Vroeg_21-05-2008\", \"\\u003Cdiv
style=\''width
:100%;
height:100%;background:#d0e6f6\''\\u003Eremco\\u003C/div\\u003E\");\n}'');
throw e }
--
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
-~----------~----~----~----~------~----~------~--~---
> the problem is with this part: > > page << "if $(''#{domid}'') {" > page << "}" > > when i use this, my script doesn''t work. , nothing happens and I am not > getting errors at all > > I dont have a clue what the problem is. > when i check with firebug i see this response: >That''s invalid syntax. It should be if( ...) { Fred> > if $(''Nacht_29-05-2008'') {--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
As an alternative to building fractured JS, check into using
page.select, which allows you to use css-style selectors to locate dom
elements. select can also be chained with methods like .any, .all,
etc so that you can iterate over the elements that you find. In this
case select(...).any(elem){elem.replace_html ''blah''} would
allow you
to replace the element if it exists. The advantage will be that the
intention of the code will be much clearer when you read it later.
AndyV
On May 21, 10:50 am, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> > the problem is with this part:
>
> > page << "if $(''#{domid}'') {"
> > page << "}"
>
> > when i use this, my script doesn''t work. , nothing happens
and I am not
> > getting errors at all
>
> > I dont have a clue what the problem is.
> > when i check with firebug i see this response:
>
> That''s invalid syntax. It should be if( ...) {
>
> Fred
>
>
>
> > if $(''Nacht_29-05-2008'') {
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:>> > That''s invalid syntax. It should be if( ...) { > > Fredoops, thanks fred, i guess i overlooked it -- 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 -~----------~----~----~----~------~----~------~--~---
whow, this is a very cool feature i didn''t know about, thanks for showing me :) AndyV wrote:> As an alternative to building fractured JS, check into using > page.select, which allows you to use css-style selectors to locate dom > elements. select can also be chained with methods like .any, .all, > etc so that you can iterate over the elements that you find. In this > case select(...).any(elem){elem.replace_html ''blah''} would allow you > to replace the element if it exists. The advantage will be that the > intention of the code will be much clearer when you read it later. > > AndyV > > On May 21, 10:50 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>-- 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 -~----------~----~----~----~------~----~------~--~---