Skip to content Skip to sidebar Skip to footer

Can't Access Elements Previously Created By Innerhtml With Javascript/prototype

I am setting the innerHTML variable of a div with contents from an ajax request: new Ajax.Request('/search/ajax/allakas/?ext_id='+extid, { method:'get', onSuccess: functi

Solution 1:

So $('akas-admin') returns null but document.getElementById("akas-admin") does not. The $ function is mostly just a wrapper for document.getElementById so it's unusual for this to break down. Have you tried using Element.extend(document.getElementById('akas-admin'))?

Do you have any other libraries loaded? Can you recreate the problem in jsFiddle?

Solution 2:

Try using live; since your form is added after the DOM has loaded. Try this:

$("#akas-admin").live('request',function(){ //Do your stuff here })

Hope this helps.

Solution 3:

When you hear hoof beats, think horses not zebras. Do you actually have an element with the id 'admincovers_content'?

Post a Comment for "Can't Access Elements Previously Created By Innerhtml With Javascript/prototype"