views:

29

answers:

1

Hello all,

I add html to a page using JQuery's html() function. This works great on most browsers except IE6.

I can work round this by adding a click event etc but I want to fix the issue without extra tape!

Any ideas why this doesn't work on IE6?

$('#button_holder').html('<a href="#" onclick="run_activity_upload(); return false;" id="save_button">Upload</a>');

Thanks, Abs

+2  A: 

Maybe you can try this?

// add html
$('#button_holder').html('<a href="#" id="save_button">Upload</a>');

// add click listener on save button
$('#save_button').click(function(e) {
    run_activity_upload();
    e.preventDefault();    // same as return false in onclick
});
Krishna K
Oh I am sorry to read only half of it - You don't want to add a separate click listener.
Krishna K
@Krishna - I was hoping not to do the above but I think it'll take me a while to figure out what's wrong with IE6 so I think the above is the correct solution annoyingly! :) It's better practice too.
Abs
@Krishna - its ok, this is the correct path.
Abs