hamza
#1
Hi,
I have the following code :
<%=link_to_function(“ä¸ | China”, update_page{|page|
page[‘tags_en’].value = “China”
page[‘tags_ch’].value = “且 }) %>
This updates two text fields with the China and ä¸. However I want to
append the values, not replace them. So I need something like this :
<%=link_to_function(“ä¸ | China”, update_page{|page|
page[‘tags_en’].value = page[‘tags_en’].value + " China"
page[‘tags_ch’].value = page[‘tags_ch’].value + " ä¸" }) %>
But that does not work. I am sure I can use the << operator and do it
via Javascript. But is there a better way ?
Thanks.
Hamza
hamza
#2
page.insert_html ‘tags_en’, :bottom, “China”
The docs are at
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html#M000431
There are a number of positions that you can put html and any html
(should
be valid) is allowed.
hamza
#3
Hi,
That does not work. I didn’t think it would because the value it is
updating is a Form text field () That is why I was using .value
Any other ideas anyone ?
Hamza
Daniel ----- wrote:
page.insert_html ‘tags_en’, :bottom, “China”
The docs are at
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html#M000431
There are a number of positions that you can put html and any html
(should
be valid) is allowed.
hamza
#4
Hamza,
You have to write a bit of JavaScript. The good news is that you can
then use an RJS helper to hide it:
<%=link_to_function(“e$BCfe(B | China”, update_page{|page|
page.append_to “tags_en”, " China"
page.append_to “tags_ch”, " e$BCfe(B"}) %>
Then define a method in your helper:
def append_to(field, value)
page << “$(’#{field}’).value = $F(’#{field}’) + ‘#{value}’”
end
On 6/27/06, Hamza Khan-Cheema [email protected] wrote:
Daniel ----- wrote:
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Cody F.
http://www.codyfauser.com
http://www.oreilly.com/catalog/rjsrails (RJS Templates for Rails)
hamza
#5
Thanks Cody, it works like a treat!
Kind Regards
Hamza
Cody F. wrote:
Hamza,
You have to write a bit of JavaScript. The good news is that you can
then use an RJS helper to hide it:
<%=link_to_function(“e$BCfe(B | China”, update_page{|page|
page.append_to “tags_en”, " China"
page.append_to “tags_ch”, " e$BCfe(B"}) %>
Then define a method in your helper:
def append_to(field, value)
page << “$(’#{field}’).value = $F(’#{field}’) + ‘#{value}’”
end
On 6/27/06, Hamza Khan-Cheema [email protected] wrote:
Daniel ----- wrote:
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Cody F.
http://www.codyfauser.com
http://www.oreilly.com/catalog/rjsrails (RJS Templates for Rails)