Qtip2未针对动态添加的控件触发

时间:2014-08-30 03:23:54

标签: javascript asp.net-mvc-4 dynamically-generated qtip2

我有一个应用程序,默认情况下我有一行元素,并有一个动态添加行的添加按钮。使用guid作为唯一标识符添加行。我正在使用qtip来显示验证错误。但是,对于动态添加的行,不会触发qtip。请帮助。以下是我的代码。

  

addNewIndentItem:function(){

    count++;
    alert("in add");
    alert(count);


    // generate a Guid value used to make the ID and NAME attributes unique for this row

    var guid = viewModel._generateGuid();
    alert(guid);
    document.getElementById('removeAnotherPhone').style.visibility = "visible";
    // using JSRENDER we get the template from the indentItemTemplate script object and replace all "index" with the guid value
    var html = $("#indentItemTemplate").render({ "index": guid });
    $("removeAnotherPhone").visible = "true";
    $("#tblIdentItems").append(html);

    // get references to the inputs that need work done to them
    var DepartmentMachineId = 'select[name="IndentItems[' + guid + '].DepartmentMachineId"]';


    var itemNameId = 'select[name="IndentItems[' + guid + '].ItemName"]';
    var CategoryNameId = 'select[name="IndentItems[' + guid + '].CategoryName"]';
    var ItemCodeId = 'select[name="IndentItems[' + guid + '].ItemId"]';
    var IssuedQuantity = 'input[name="IndentItems[' + guid + '].IssuedQuantity"]';



    // False means we are editing an indent so disable fields
    if ($("#IsCreate").val() == "False") {
        $(IssuedQuantity).blur(CalcBalance);
    }
    else {
        // configure the custom drop down for any rows of items that were created when the page was first generated
        alert("subsequent load");
        $(DepartmentMachineId);           
        $(itemNameId).change(GetItemCategories);
        $(CategoryNameId).chosen().change(GetItems);
        $(ItemCodeId).chosen().change(SetItem);           

    }

我添加了一个js文件jquery.qtip.js,它会在第一次加载时调用qtip

0 个答案:

没有答案