views:

74

answers:

3

Here is my spaggeti code

$("#table_exams tbody tr").click(function ()
{
    window.location.hash="#" +$(this).attr("exam_ID");
     window.location.href="/medilab/prototypes/exams/edit?examId=" + $(this).attr("exam_ID") +"&referer=" + referer;

   row_select(this);
});

$("#table_exams tbody tr td a").click(function ()
{

    window.location.hash="#" +$(this).parent().parent().attr("exam_ID");        
    var where="/medilab/prototypes/exams/edit?examId=" + $(this).parent().parent().attr("exam_ID") +"&referer=" + referer;
    window.open(where);
    row_select($(this).parent().parent());
    alert("propaganda");
    event.stopPropagation();
    event.preventDefault();
    return false;

});

The problem is that when this function is triggered

$("#table_exams tbody tr td a").click(function ()
{

the other function is triggered also.... only in IE... What can i do for this????

+2  A: 

This line:

$("#table_exams tbody tr td a").click(function () {

Needs to be this:

$("#table_exams tbody tr td a").click(function (event) {

You're not passing the proper event into the function, I'd imagine you're getting an undefined on event.stopPropagation(); in IE.

Nick Craver
+1  A: 

You need to pass the event into the function. In both functions, change .click(function () to .click(function (event)

You can also add alert(event.isPropagationStopped()) to debug further if required.

dingle_thunk
A: 

I think that event.stopPropagation(); should do the trick, see jQuery docs.

$("#table_exams tbody tr td a").click(function (event)
{
    event.stopPropagation();
    window.location.hash="#" +$(this).parent().parent().attr("exam_ID");        
    var where="/medilab/prototypes/exams/edit?examId=" +     $(this).parent().parent().attr("exam_ID") +"&referer=" + referer;
    window.open(where);
    row_select($(this).parent().parent());
    alert("propaganda");
    return false;    
});
Dustin Laine
He already has that, you now have it twice in there :)
Nick Craver
Thanks, I meant to remove his.
Dustin Laine