开发者

Another Internet Explorer problem... JQuery events

开发者 https://www.devze.com 2022-12-27 00:41 出处:网络
Here is my spaggeti code $(\"#table_exams tbody tr\").click(function () { window.location.hash=\"#\" +$(this).attr(\"exam_ID\");

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_I开发者_如何学运维D");        
    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????


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.


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.


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;    
});
0

精彩评论

暂无评论...
验证码 换一张
取 消