jerikmail-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Nov-24 12:38 UTC
$(element_id).insert is not a function
I have implemented the following function into my application.js
function create_part( element_id ) {
foo = ''<h1>test</h1>''
$( element_id ).insert( foo , { position: content } )
}
If i call this function i get the following error in the Error-
console:
Fehler: $(element_id).insert is not a function
Quelldatei: http://localhost:3000/javascripts/application.js?1195905778
Zeile: 3
If I hav a look at the examples in http://www.prototypejs.org/api/element
I cannot see an error in my definition, and the function should be
recognized if I have included the prototype.js, what I have...
If i test with alert( $(element_id)), the id of the element will pop-
up. So it should be working. That why I am a bit confused?
Some ideas ?
cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Proper usage is like this
function create_part( element_id ) {
foo = ''<h1>test</h1>''
$( element_id ).insert( { top: foo} );
}
--- OR ---
function create_part( element_id ) {
foo = ''<h1>test</h1>''
Element.insert( $( element_id ) , { position: content } );
}
Someone correct me if I''m wrong
On Nov 24, 1:38 pm,
"jerikm...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org"
<jerikm...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> I have implemented the following function into my application.js
>
> function create_part( element_id ) {
> foo = ''<h1>test</h1>''
> $( element_id ).insert( foo , { position: content } )
>
> }
>
> If i call this function i get the following error in the Error-
> console:
>
> Fehler: $(element_id).insert is not a function
> Quelldatei:http://localhost:3000/javascripts/application.js?1195905778
> Zeile: 3
>
> If I hav a look at the examples inhttp://www.prototypejs.org/api/element
> I cannot see an error in my definition, and the function should be
> recognized if I have included the prototype.js, what I have...
>
> If i test with alert( $(element_id)), the id of the element will pop-
> up. So it should be working. That why I am a bit confused?
>
> Some ideas ?
>
> cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
1st: Are you sure $( element_id ) returns an element, element_id must
be element id or element it self.
2nd: the code must be $( element_id ).insert(foo)
insert(element, { position: content }) <- what is written in the
manual is strange (+ there weren''t no examples :( )
It''s so if you use Element.insert(element, { position: content }) but
when using extended element you can just
$(element).insert({position: content }); as position can be before,
after, top, bottom, and content is in your case foo
you can also write $(element).insert(foo) witch is same as $
(element).insert({bottom: foo})
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---