# Re: Weird error now - RJS not working

**URL:** <https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768>\
**Category:** Rails\
**Created:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768 "2006-11-07T10:55:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/1 "2006-11-07T10:55:49Z")

</div>

try {  
new Insertion.Bottom(“canskills”, "

\n \<td td  
align=“LEFT”\>Guitarist\n \<td td align=“LEFT”\>Advanced\n 5 + years\n 4+ years ago\n\n\n\n\n"); Form.reset("canskill-form"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('new Insertion.Bottom(\"canskills\", \"\n Guitarist\n Advanced\n 5 + years\n 4+ years ago\n\n\n\n\n\");\nForm.reset(\"canskill-form\");'); throw e }

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/2 "2006-11-07T10:55:56Z")

</div>

And the problem is?

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:56am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/3 "2006-11-07T10:56:14Z")

</div>

On 11/2/06, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And the problem is?

That’s what I"m trying to figure out. Is my question to vague ? I  
think  
it’s getting closer.

Stuart

On 11/2/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> >

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:57am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/4 "2006-11-07T10:57:54Z")

</div>

On 11/2/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #this starts the table with the inputted information ................................... def create \n \n\n\n\n\n"); Reading more perhaps this is not an error as much as it's showing me the
> 
> javascript.  
> One thing is that when I hit submit, and the rjs text message appears  
> I’m  
> back at a different URL.
> 
> the form and table sits at /id/candidates/canskills/new  
> yet after submit, the rjs quotes above appears at  
> /id/candidate/canskills
> 
> ?  
> Stuart
> 
> | 1 year ago |

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:56am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/5 "2006-11-07T10:56:49Z")

</div>

Still not sure what I’m missing here. I’ve done some reading up with  
the  
RJS Templates book.  
Here is what I’m trying to do.

I have a page, on the bottom portion is a form, on the top is a table.  
User  
makes entry into form,hits submit table gets another row.  
I’ll probably add an additonal button at some point to exit the screen.

This is the form (at least the important part -

 #this starts the table with the inputted information \<%= render :partial =\> 'canskills/canskill' ,:collection =\> @ candidate.canskills %\>

| Skill | Skill level | Experience | Last use |
| --- | --- | --- | --- |

Now the form itself : \<% remote\_form\_for :canskill, :url =\> canskill\_url, :html =\> { :id =\> 'canskill-form' }, :candidate\_id =\> @candidate\_id do |form| %\> #various fields................ ................................... ................................... %= submit\_tag "add skill" %\>

I have a create.rjs to accompany the controller action create.  
rjs :  
page.insert\_html :bottom, ‘canskills’, :partial =\> ‘canskill’  
page.form.reset ‘canskill-form’

Then the controller action:  
pretty simple:

def create  
@canskill = Canskill.new(params[:canskill])  
@candidate\_id = params[:candidate\_id]  
end

However on submit all I get currently is this rjs error page -

try {  
new Insertion.Bottom(“canskills”, "\n\<div id="new-canskill"\>\n

Internet engineer\n Intermediate\n 3 - 4 years\n 1 year ago\n \n\n\n\n\n"); Form.reset("canskill-form"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('new Insertion.Bottom(\"canskills\", \"\n
\n Internet engineer\n Intermediate\n 3 - 4 years\n 1 year ago\n
\n\n\n\n\n\");\nForm.reset (\"canskill-form\");'); throw e }

I gather it’s telling me to try something , ? not sure.  
Can really use some help / pointers, guidance.

Stuart

On 11/2/06, Dark A. \<removed\_email\_address@domain.invalid \> wrote:

> > > Form.reset(“canskill-form”);
> > > 
> > > >
> 
> –  
> [Dark ambient - Wikipedia](http://en.wikipedia.org/wiki/Dark_ambient)

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:58am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/6 "2006-11-07T10:58:06Z")

</div>

Bump . sorry still stuck on this and hopefully someone can help.  
I’m wondering if my rest based controller is the problem.  
I don’t think the URL should be changing.

On 11/3/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > User makes entry into form,hits submit table gets another row.  
> > Now the form itself :  
> > page.form.reset ‘canskill-form’
> > 
> > Insertion.Bottom("canskills", "\n\<div id=\“new-canskill\”\>\n \<td td align=\“LEFT\”\>  
> > One thing is that when I hit submit, and the rjs text message appears I’m  
> > back at a different URL.
> 
> the form and table sits at /id/candidates/canskills/new  
> yet after submit, the rjs quotes above appears at /id/candidate/canskills
> 
> ?  
> Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/7 "2006-11-07T10:59:19Z")

</div>

On Nov 3, 2006, at 4:58 AM, Dark A. wrote:

> Bump . sorry still stuck on this and hopefully someone can help.  
> I’m wondering if my rest based controller is the problem.  
> I don’t think the URL should be changing.

Hey Stuart-

```
The reason you are having trouble is because you cannot replace

```

normal table rows with ajax. You have to wrap each row in a tbody and  
use that to replace the rows:

With your table, ensure that you have the proper

 tag around  
all elements. Have the links within each of the TR’s that should  
display the info below have an id like so

| 

| | link for info with id... | link for info with id... |

 |
| 

| | link for info with id... | link for info with id... |

 |

And you should be able to use RJS like so…

page.insert\_html :bottom, params[:row], render(:partial =\>  
‘rowHelpInfo’)

Cheers-

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/8 "2006-11-07T10:59:22Z")

</div>

On 11/3/06, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey Stuart-
> 
> ```
> The reason you are having trouble is because you cannot replace
> 
> ```
> 
> normal table rows with ajax. You have to wrap each row in a tbody and  
> use that to replace the rows:
> 
> With your table, ensure that you have the proper tag around  
> all elements. Have the links within each of the TR’s that should  
> display the info below have an id like so

Links being what, the generate data ? and which id’s are you speaking  
about  
?

Stuart

\> \> \> page.insert\_html :bottom, params[:row], render(:partial =\> \> \> \> \> \> \>

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

| link for info with id... |

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/re-weird-error-now-rjs-not-working/74768/9 "2006-11-07T10:59:36Z")

</div>

Sorry Stuart, I just pasted an example of the table and I forgot to  
remove that part about links, you can ignore that. The important bit  
is to use tags to wrap each tr row. You put an id on the  
tbody’s and then replace a whole tbody with a new tr in it to replace  
a table row. You cannot replace tr tags directly.

```
So here is an example table in a template that I use to replace

```

table rows with ajax. This is just an example to get your started.\

## Applications

\<% for app in @apps %\>

  
  
  

```
	<td><span style='float: right;'><%= link_to image_tag

```

(‘pencil\_go.png’), edit\_app\_path(app) %\>  
\<%= link\_to image\_tag(‘cross.png’), app\_path(app), :confirm =\> ‘Are  
you sure?’, :method =\> :delete %\>

  
  
\<% end %\>

| Name | Svn url | Actions |
| --- | --- | --- |
| \<%= link\_to app.name, app\_path(app) %\> | \<%= truncate(app.svn\_url) %\> |
| \<%= link\_to image\_tag('/images/buttons/new.gif'), new\_app\_path %\> |
| --- |

the iimportant part is to make a unique id on each tag . and  
then when you replace a row with ajax, you replace the entire tbody.  
So in an rjs response you send back something like thisL

```
 <tbody id='<%= app.dom_id %>'>
  <tr>
	<td><%= link_to app.name, app_path(app) %></td>
	<td><%= truncate(app.svn_url) %></td>

	<td><span style='float: right;'><%= link_to image_tag

```

(‘pencil\_go.png’), edit\_app\_path(app) %\>  
\<%= link\_to image\_tag(‘cross.png’), app\_path(app), :confirm =\> ‘Are  
you sure?’, :method =\> :delete %\>

Hope that helps.

Cheers-  
-EZrta

On Nov 3, 2006, at 11:27 AM, Dark A. wrote:

> 'rowHelpInfo')
> 
> [Dark ambient - Wikipedia](http://en.wikipedia.org/wiki/Dark_ambient)
> 
> >

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)
