# Element.insert\_html is not function

**URL:** <https://www.ruby-forum.com/t/element-insert-html-is-not-function/189473>\
**Category:** Rails\
**Created:** [June 1, 2010, 3:03pm UTC](https://www.ruby-forum.com/t/element-insert-html-is-not-function/189473 "2010-06-01T15:03:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@santoshd](https://www.ruby-forum.com/u/santoshd)\
**Post date:** [June 1, 2010, 3:03pm UTC](https://www.ruby-forum.com/t/element-insert-html-is-not-function/189473/1 "2010-06-01T15:03:41Z")

</div>

Hi

I have created the application by following the railcast video

> **[\#74 Complex Forms Part 2 - RailsCasts](http://railscasts.com/episodes/74-complex-forms-part-2)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

However I am getting this error when I click “add element”

RJS error:

TypeError: Element.insert is not a function

and then

Element.insert(“docs”, { bottom: "\<div class="doc"\>\n\n  
Doc: \<input …etc

I have added the \<%= javascript\_include\_tag :defaults %\> in layout  
files also

here is my rjs line  
\<%= render :partial =\> ‘task’, :collection =\> @project.tasks %\>

please help me in this regards.

---

<div class="post-metadata">

**Author:** ![santoshd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@santoshd](https://www.ruby-forum.com/u/santoshd)\
**Post date:** [June 1, 2010, 6:34pm UTC](https://www.ruby-forum.com/t/element-insert-html-is-not-function/189473/2 "2010-06-01T18:34:46Z")

</div>

Hi,

Please verify that all included javascript files get successfully  
loaded into your html page.

–  
Volker

Santosh D. schrieb:

---

<div class="post-metadata">

**Author:** ![santoshd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@santoshd](https://www.ruby-forum.com/u/santoshd)\
**Post date:** [June 2, 2010, 8:06am UTC](https://www.ruby-forum.com/t/element-insert-html-is-not-function/189473/3 "2010-06-02T08:06:40Z")

</div>

Hi,

```
I inserted required java script files in my html page that is 

```

new.html.erb

Plaese verify the file…

#Projects/new.html.erb

\<% form\_for :project, :url =\> projects\_path do |f| %\>

Name: \<%= f.text\_field :name %\>

 \<%= render :partial =\> 'task', :collection =\> @project.tasks %\> 

\<%= link\_to\_function “Add a Task” do |page|

```
page.insert_html:bottom, :tasks, :partial => 'task', :object => 

```

Task.new  
end %\>

\<%= submit\_tag "Create Project" %\>

\<% end %\>

#My controller i.e projects

class ProjectsController \< ApplicationController

def index  
@projects = Project.find(:all)  
end

def new  
@project = Project.new  
@project.tasks.build

end

def create  
@project = Project.new(params[:project])  
if @project.save  
flash[:notice] = “Successfully created project and tasks.”  
redirect\_to projects\_path  
else  
render :action =\> ‘new’  
end  
end

def edit  
@project = Project.find(params[:id])  
end

def update  
params[:project][:existing\_task\_attributes] ||= {}

@project = Project.find(params[:id])  
if @project.update\_attributes(params[:project])  
flash[:notice] = “Successfully updated project and tasks.”  
redirect\_to project\_path(@project)  
else  
render :action =\> ‘edit’  
end  
end

end
