I don't think you will have too much luck achieving what you want with live()
, as jQuery only supports event bubbling and not event capturing. The design decision was probably due to the fact the IE does not support event capturing, even though W3C's speicification has the flexibility for both.
Your best bet is to attach a click event to the remove button right after it is inserted into the DOM (to stop the event propagation) before you re-initiate the accordion. You may need to take care not to bind click event to the existing remove buttons multiple times.
The pseudocode would look something like this:
- call
.accordion('destory')
on the current accordion
- create the new element, i.e.
<h2>...<a class="revmoe">...</a></h2><div>...</div>
- insert the new element to the existing accordion
- bind a click event to the remove button in the new element to stop event propagation
- initiate the accordion, i.e.
.accordion({..})
SO posts on event capturing in jQuery: