I think my problem is something similar and I haven't found a solution either. I want to make some click events on the loaded elements in the requested. I get the responseElements in the onSuccess/onComplete function but the events aren't attached to the elements. I know it's because the domready isn't finished in the onSuccess/onComplete.
I couldn't manage to get your code to work, Fábio. Aarons code became to complicated. This code works if I call the request from the content loaded within On Sep 26, 2:23 am, Pedro Moreira <[email protected]> wrote: > Fábio, > > your code makes sense but I still can't make this work. Any ideia why? > > On Sep 25, 9:03 pm, Fábio M. Costa <[email protected]> wrote: > > > > > I understand it, i had passed thought it before. > > The problem here is that the javascript is evaluated before the update is > > done, so you dont have the popup on the DOM and cant addEvents to it. Theres > > a way to do it, i dont like it but i'll show you as its the only i got. > > > var editVenueBox = $('edit_venue_box'); > > new Request.HTML({ > > url: '/admin/venue/' + venue_id, > > evalScripts: false, > > onSuccess: function(responseTree, responseElements, responseHtml, > > responseJs){ > > editVenueBox.set('html', responseHtml); > > $exec(responseJs); > > } > > > }).send(); > > > Did you get it? Still i dont know why its done like this, shouldn't the > > order be changed (to the core-devs)? > > > -- > > Fábio Miranda Costa > > Solucione Sistemas > > Engenheiro de interface > > > On Fri, Sep 25, 2009 at 3:06 PM, Pedro Moreira > > <[email protected]>wrote: > > > > Hello everyone, > > > > I've been working on a really fun project but today something got on > > > my nerves. I searched for some solutions but none worked for me. I > > > even found one post somewhere with something similar: > > >http://www.mooforum.net/general12/domready-after-request-html-t1743.html > > > > So... There's a page with a bunch of rows on a table and each row as a > > > link "edit". On that page I add an event to each link when the user > > > clicks on it. This event makes a Request.HTML and the html response > > > will be set by the update option on a lightbox-like div, a better > > > looking pop up window. On this new page I have some input fields and > > > an input button which I want to be able to click to trigger an event > > > (a request to save the input fields). > > > > Problem is: I can't add events on the pop up window! > > > > Code-wise: > > > page.php > > > ... > > > window.addEvent('domready', function() > > > { > > > ... > > > > $each($$('a.edit_venue_link'), function(item) > > > { > > > item.addEvent('click', function() > > > { > > > var venue_id = item.get('venue_id'); > > > > new Request.HTML( > > > { > > > url: '/admin/venue/' + venue_id, > > > update: 'edit_venue_box' > > > }).send(); > > > } > > > ); > > > } > > > ); > > > ... > > > > /admin/view/:num (it's a controller which triggers a view with...) > > > ... > > > <script> > > > > window.addEvent('domready', function() > > > { > > > alert($('submit_button').get('text')); > > > > $('submit_button').addEvent('click', function() > > > { > > > alert('is it working?'); > > > }); > > > ... > > > > The alert with the submit_button text works but all the events I try > > > to add don't. > > > > Am I doing something wrong? > > > > I tried setting evalScripts true and false but it still doesn't work. > > > The solution on the link I wrote about doesn't work either...
