Question least to me. This code used to work fine. I'm pretty sure nothing has changed, but now all of the sudden it behaves oddly. Basically I'm trying to create inline editing functionality. When the user clicks on the link, it dynamically generates a textbox and a confirm and cancel link. I'm having problems with the cancel link not removing everything in the cell.


<td class="bid">
   <a href="javascript:" class="102093" title="Click to modify bid">$0.45</a>

Binding jQuery (in $(function())):

$('.bid a').live('click', renderBidChange);
$('.report_table .cancel').live('click', cancelUpdate); 

renderBidChange (this function creates the dynamic elements):

function renderBidChange(){
    var cpc = $(this);
    var value = cpc.text().replace('$', '');
    var cell = cpc.parent('.bid');

    var input = document.createElement('input');
    $(input).attr({type:'text',class:'dynamic cpc-input'}).val(value);

    var accept = document.createElement('a');
      'title':'Accept Changes'}).text('Accept Changes');

    var cancel = document.createElement('a');
      'title':'Cancel Changes'}).text('Cancel Changes');


cancelUpdate this function just removes everything visible (all the dynamic junk in this case) in the cell and shows what used to be there.

function cancelUpdate(){
    var cell = $(this).parent();

However, for some reason, the cancel link remains after it is clicked! Everything else is removed except that. W T F

Thanks for any insight you're able to provide! I'm sure it's just some stupid little detail I'm over[caffeinatedly]looking...

UPDATE Immediately after posting this I epiphanied that it may be a CSS issue, but after double checking my code, it is not.

Was it helpful?


You need a slight tweak here:

$('.bid a:not(.cancel)').live('click', renderBidChange);

Since you've moved to .live(), the first function is also running with a click on cancel :)


what happens if you change:

$('.report_table .cancel').live('click', cancelUpdate); 


$('.bid .cancel').live('click', cancelUpdate); 

I don't expect a solution, but I'm just doublechecking

What's the "live" function for .accept? Does it work (presumably so)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow