Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is $(document).ready(function(){}) is firing twice. I have already checked whether the js file is linked twice in any page or not.but it is not the issue. I have already tried with a variable and set it's value initially to 'false' and then set it to 'true' inside $(document).ready. Please check from the code bellow.

JavaScript
var _DONE = false;

$(document).ready(function () {    
    if (_DONE == true) {           
        return;
    }  
    _DONE = true;
    InitUserAllocationRoleDD();
    var grid = $("#CWUsersAllocationGrid").data("kendoGrid");
    grid.bind("dataBound", function (e) { setGeneralGridHeight('CWUsersAllocationGrid') });
});


This piece of code is also not working.

Actual Code:

C#
 $(document).ready(function () {
    InitUserAllocationRoleDD();
    var grid = $("#CWUsersAllocationGrid").data("kendoGrid");
    grid.bind("dataBound", function (e) { setGeneralGridHeight('CWUsersAllocationGrid') });
});

function InitUserAllocationRoleDD() {
    GetDomainUsers();
    $('#cwallocationrole').unbind('change');
    $('#cwallocationrole').on('change', function () {
        if ($(this).find('option:selected').text() == '--Select--') {
            DomainNameSelector.val("");
            SequenceNumberSelector.val("");
            UserDefinedTextSelector.val("");
            return false;
        }
        selectedvalue = $(this).val();
        SelectedText = $(this).find('option:selected').text();
        SplitValue = selectedvalue.split("_");
        SplitText = SelectedText.split(":");
        $('#DomainName').val(SplitValue[1] + "_");
        $('#SequenceNumber').val("_" + SplitValue[2]);
        $('#UserDefinedText').val('');
    });
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900