# Problem with client-side RJS using update\_page

**URL:** <https://www.ruby-forum.com/t/problem-with-client-side-rjs-using-update-page/119662>\
**Category:** Rails\
**Created:** [November 9, 2007, 12:09am UTC](https://www.ruby-forum.com/t/problem-with-client-side-rjs-using-update-page/119662 "2007-11-09T00:09:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 9, 2007, 12:09am UTC](https://www.ruby-forum.com/t/problem-with-client-side-rjs-using-update-page/119662/1 "2007-11-09T00:09:36Z")

</div>

I tried to use RJS inside my rhtml template like this:

\<%= select\_tag “price”, … %\>  
\<%= observe\_field :price, :function =\> update\_page do |page|

page.insert\_html :after, ‘price’, “3”  
end %\>

But when I refresh the browser, I get the following error from the rthml  
engine:  
You have a nil object when you didn’t expect it! The error occurred  
while evaluating nil.bind

How come?

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 9, 2007, 12:21am UTC](https://www.ruby-forum.com/t/problem-with-client-side-rjs-using-update-page/119662/2 "2007-11-09T00:21:17Z")

</div>

Hmm, so it appears if I add brackets to the options hash for  
update\_page, it  
would work:  
\<%= select\_tag “price”, … %\>  
\<%= observe\_field :price, { :function =\> update\_page do |page|

page.insert\_html :after, ‘price’, “3”  
end }  
%\>

I’m aware of the need for explicit hash when it’s not the last argument,  
but  
why is bracket required in this case?

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 9, 2007, 9:48am UTC](https://www.ruby-forum.com/t/problem-with-client-side-rjs-using-update-page/119662/3 "2007-11-09T09:48:59Z")

</div>

On 8 Nov 2007, at 23:20, Eric L. wrote:

> I’m aware of the need for explicit hash when it’s not the last  
> argument, but why is bracket required in this case?

I expect it thought that you meant

> observe\_field(:price, :function =\> update\_page) do |page|  
> page.insert\_html :after, ‘price’, “3”  
> end

Fred
