[EP-tech] Re: Problem with EPrints and adding javascript to a new created field.

Sebastien Francois sf2 at ecs.soton.ac.uk
Tue May 21 16:50:47 BST 2013



Does your custom javascript adds some event handlers to the component
(to detect that the value has changed)?

> Yes, actually what I do is to detect when the select elements (dropdown
> menu) I've added change their default value and if so, then execute my
> ajax call..
>
>
>> If so, I suspect those handlers will get removed/erased when pressing
>> [More input rows] because the component is then reloaded (via an AJAX
>> callback).
>>
>> Seb.
> And could I do in order to make it work?
That's a tricky one... you can only re-apply the handlers after the ajax 
callback returns. And as far as I know there are no ways to detect the 
DOM has changed and/or the new elements have been inserted into the DOM...

You could perhaps add another "click" handler on the [More input rows] 
button that triggers a piece of code that periodically looks for the 
<select> element you need. Once the <select> is in the DOM, you can 
re-apply your handler. Might work, might not, I'm not sure.

Also, if you don't need jQuery for anything else, I'd suggest you write 
your code using the Prototype library which comes with EPrints.

Good luck,
Seb.



More information about the Eprints-tech mailing list