Hi Guilherme, On Wednesday 04 November 2009 Guilherme Aiolfi wrote: > I'm pretty sure it's simple but I not used to low level stuff. What I want > to do is create a click event in the recently created button to remove its > parent div: > > qx.bom.Collection.query("#add_category_button").addListener("click" > , function(e) > { > var html = "<div class='category'><input > name='cat[name]'/><input class='category_remove_button' type='button' > value='remover' /></div>"; > e.preventDefault(); > qx.bom.Collection.create(e.getTarget()).before(html); // is > there a cleaver way to do that? > return false; > }, this); > > Adding: > qx.bom.Collection.query(".category_remove_button").addListener("click", > function(e) { }, this); > > doesn't help because the element is not created yet. I think a possible solution can be to create the collection inside the listener method and directly add the listener there.
--snip-- // instead of qx.bom.Collection.create(e.getTarget()).before(html); // write var html = qx.bom.Collection.html("<div class='category'><input name='cat[name]'/><input class='category_remove_button' type='button' value='remover' /></div>"); qx.bom.Collection.create(e.getTarget()).before(html[0]); html.find(".category_remove_button").addListener("click", function(e) {}); --snip-- This way you have the inserted HTML as collection and you should be able to add a listener to it. I hope this works - I have not tested this code. cheers, Alex ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel