Element.insert_html is not function

Hi

I have created the application by following the railcast video

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.

Hi,

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


Volker

Santosh D. schrieb:

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