Search code examples
javascriptjquerylocation-href

jQuery dynamically change onclick location.href


This works in firefox but doesn't do anything in IE:

$("#_results").autocomplete({
    source: data,
    minLength: 0,
    select: function(event, ui) {
        $("#log").empty();
        log(ui.item.lname + ", " + ui.item.fname + " " + ui.item.sso);
        log("Currently in " + ui.item.currentRotation + " rotation");
        log("Graduated from: " + ui.item.college);
        log("More details can be viewed by clicking here");
        $("#log").attr("onclick", "location.href=\'" + ui.item.dataformEntry + "\'\;");
    }

Specifically $("#log").attr("onclick", "location.href=\'" + ui.item.dataformEntry + "\'\;");

Is there another way to do this?


Solution

  • have you already tried with

    $("#log").bind("click", function() { 
        location.href = ui.item.dataformEntry 
    });