Greetings!
What is up with the syntax of this thing? I mean, if the only thing I can send
back using :with is the field being observed, then why in the world is the
syntax so convoluted? For example, what I''ve been able to get working
is:
<%= text_field_tag(''date'', illness_date, :size => 30)
%></p>
<%= observe_field(''date'', :url => {:action =>
''update_date'', :id => illness_id}, :with =>
"''idate=''+$(''date'').value" ) %>
Of course, maybe I''m just doing it wrong. I suppose it might make some
sense if it''s possible to send more than one params value back with the
:with option. Does anybody know anything about how that might be possible?
I''ve spent a day and a half trying to figure it out and
haven''t been able to get anything but the above to work.
TIA,
Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060626/e3b8ef4a/attachment.html
Hi Bill,
You can send anything back to your script. The syntax is pure javascript
that is eval''d. You can use it to build a custom parameter string.
I''m not
sure if it needs to be escaped to be url encoded or not.
:with => %q{"idate=" + $(''date'').value +
"&some_other_value=" +
$(''some_other_field'').value}
Hope this is strictly correct. I''m sure someone will correct me
otherwise
:) at least I hope so.
On 6/26/06, Bill Walton <bill.walton@charter.net>
wrote:>
> Greetings!
>
> What is up with the syntax of this thing? I mean, if the only thing I can
> send back using :with is the field being observed, then why in the world is
> the syntax so convoluted? For example, what I''ve been able to get
working
> is:
>
> <%= text_field_tag(''date'', illness_date, :size =>
30) %></p>
> <%= observe_field(''date'', :url => {:action =>
''update_date'', :id =>
> illness_id}, :with =>
"''idate=''+$(''date'').value" ) %>
>
> Of course, maybe I''m just doing it wrong. I suppose it might make
some
> sense if it''s possible to send more than one params value back
with the
> :with option. Does anybody know anything about how that might be possible?
> I''ve spent a day and a half trying to figure it out and
haven''t been able to
> get anything but the above to work.
>
> TIA,
> Bill
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060626/08fd6e99/attachment.html
Hi Daniel,
Thanks. I haven''t tried the %q syntax (although that''s about
the _only_ thing I haven''t tried!). I''ll give it a shot. I
did find something on the wiki just after I sent my original post that implies
you can only send back one params value _but_ you can put a bunch of stuff into
the one string you''ll get back and then parse out the pieces. I
definitely hope your approach works, but at least it looks like there''s
a way to do what I need, even if it''s coyote-ugly ;-)
Thanks again,
Bill
----- Original Message -----
From: Daniel N
To: rails@lists.rubyonrails.org
Sent: Monday, June 26, 2006 8:57 AM
Subject: [Norton AntiSpam] Re: [Rails] syntax for observe_field( :with =>
Hi Bill,
You can send anything back to your script. The syntax is pure javascript that
is eval''d. You can use it to build a custom parameter string.
I''m not sure if it needs to be escaped to be url encoded or not.
:with => %q{"idate=" + $(''date'').value +
"&some_other_value=" +
$(''some_other_field'').value}
Hope this is strictly correct. I''m sure someone will correct me
otherwise :) at least I hope so.
On 6/26/06, Bill Walton <bill.walton@charter.net> wrote:
Greetings!
What is up with the syntax of this thing? I mean, if the only thing I can
send back using :with is the field being observed, then why in the world is the
syntax so convoluted? For example, what I''ve been able to get working
is:
<%= text_field_tag(''date'', illness_date, :size =>
30) %></p>
<%= observe_field(''date'', :url => {:action =>
''update_date'', :id => illness_id}, :with =>
"''idate=''+$(''date'').value" ) %>
Of course, maybe I''m just doing it wrong. I suppose it might make
some sense if it''s possible to send more than one params value back
with the :with option. Does anybody know anything about how that might be
possible? I''ve spent a day and a half trying to figure it out and
haven''t been able to get anything but the above to work.
TIA,
Bill
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
------------------------------------------------------------------------------
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060626/f0568dc6/attachment-0001.html
On 6/27/06, Bill Walton <bill.walton@charter.net> wrote:> > Hi Daniel, > > Thanks. I haven''t tried the %q syntax (although that''s about the _only_ > thing I haven''t tried!). I''ll give it a shot. I did find something on the > wiki just after I sent my original post that implies you can only send back > one params value _but_ you can put a bunch of stuff into the one string > you''ll get back and then parse out the pieces. I definitely hope your > approach works, but at least it looks like there''s a way to do what I need, > even if it''s coyote-ugly ;-) >Yeah, it is very ugly. I guess you could wrap it up into a helper. There''s no doubt a much better way to do this. def with_fields_for_observe( *fields ) fields.flatten! out = "" join = "" fields.each do |field| out << join << "''#{field.to_s}='' + $(''#{field.to_s}'').value" join = " + ''&'' + " end out end Then you could call the with parameter with :with => with_fields_for_observe( :a_field_id, ''some_other_id'', [:yet_another_id, :last_one] ) The access in your controller should be similar to a normal parameter string. Best to check the output tho. Hope this minimises the ugly to a reasonable level. ;) Thanks again,> Bill > > ----- Original Message ----- > *From:* Daniel N <has.sox@gmail.com> > *To:* rails@lists.rubyonrails.org > *Sent:* Monday, June 26, 2006 8:57 AM > *Subject:* [Norton AntiSpam] Re: [Rails] syntax for observe_field( :with > => > > Hi Bill, > > You can send anything back to your script. The syntax is pure javascript > that is eval''d. You can use it to build a custom parameter string. I''m not > sure if it needs to be escaped to be url encoded or not. > > :with => %q{"idate=" + $(''date'').value + "&some_other_value=" + > $(''some_other_field'').value} > > Hope this is strictly correct. I''m sure someone will correct me otherwise > :) at least I hope so. > > > > On 6/26/06, Bill Walton <bill.walton@charter.net> wrote: > > > > Greetings! > > > > What is up with the syntax of this thing? I mean, if the only thing I > > can send back using :with is the field being observed, then why in the > > world is the syntax so convoluted? For example, what I''ve been able to get > > working is: > > > > <%= text_field_tag(''date'', illness_date, :size => 30) %></p> > > <%= observe_field(''date'', :url => {:action => ''update_date'', :id => > > illness_id}, :with => "''idate=''+$(''date'').value" ) %> > > > > Of course, maybe I''m just doing it wrong. I suppose it might make some > > sense if it''s possible to send more than one params value back with the > > :with option. Does anybody know anything about how that might be possible? > > I''ve spent a day and a half trying to figure it out and haven''t been able to > > get anything but the above to work. > > > > TIA, > > Bill > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > ------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060626/fd6809b4/attachment.html