jquery单击函数将不执行

jquery单击函数将不执行,jquery,checkbox,Jquery,Checkbox,这是我的代码,第一次单击将获得一些复选框列表,然后单击每个复选框将触发第二次单击功能,使复选框列表动态刷新,并根据已选中的内容列出项目。第一次单击功能工作正常,可以获取所有复选框列表,但当您单击复选框时,第二次单击将不会执行。。。我感觉到那里有一些愚蠢的虫子,但不知道会在哪里 // functions to capture the selection of the template sidebar $(function () { $('.sidebar li > a').on('cl

这是我的代码,第一次单击将获得一些复选框列表,然后单击每个复选框将触发第二次单击功能,使复选框列表动态刷新,并根据已选中的内容列出项目。第一次单击功能工作正常,可以获取所有复选框列表,但当您单击复选框时,第二次单击将不会执行。。。我感觉到那里有一些愚蠢的虫子,但不知道会在哪里

// functions to capture the selection of the template sidebar
$(function ()
{

  $('.sidebar li > a').on('click', function (e)
  {
    var children = $(this).parent('li').find(' > ul > li');

    if (children.length == 0)
    {
      var templateName = children.context.id;

      $.ajax({
        type: "Post",
        url: "SingleViewNew2.aspx/AddParametersToSidebar",
        contentType: "application/json",
        dataType: "json",
        data: "{theTemplateName:'" + templateName + "'}",
        success: function (data) //callback function, VIF!! all the follow up content js should be included in this
        {
          // once in the template, 1,beautify the scroll bar 2,click checkbox or radio 3,launch report
          //1
          var item = data.d;
          var sidebar = $('#right-sidebar');
          sidebar[0].innerHTML = item;
          $('.param_list').niceScroll({ cursorcolor: "##061B58" });
          //2
          },
        error: function (err) { alert("oh no"); }
      });

    }
    else if (children.is(":visible"))
    {
      children.hide('fast');
    } else
    {
      children.show('fast');
    }
    e.stopPropagation();
  });

   $(":checkbox").click(function ()
    {
        var checkThisItem = $(this);
        if (checkThisItem.checked == null)
         {
              checkThisItem.checked = false;

            }
            else
            checkThisItem.checked = true;
            // here get all the current checked items and then send them back to diplay the dependencyva
            //var allItems = $("input");
            var allCheckedItem = $(":checked:checked");
            var passAllCheckedItem = new Array();
            for (var i = 0; i < allCheckedItem.length; i++)
            {
                passAllCheckedItem[i] = allCheckedItem[i].name + "__" + allCheckedItem[i].defaultValue;
              }
            passAllCheckedItem = JSON.stringify(passAllCheckedItem);
            $.ajax(
            {
              type: "Post",
              url: "SingleViewNew2.aspx/updateParametersToSidebar",
              contentType: "application/json",
              traditional: true,
              dataType: "json",
              data: "{allCheckedItems :'" + passAllCheckedItem + "'}",
              error: function (err) { alert("oh no"); },
              success:function(data)
              {
              var item = data.d;
              var sidebar = $('#right-sidebar');
              sidebar[0].innerHTML = item;
              $('.param_list').niceScroll({ cursorcolor: "##061B58" });
              },

            });
          });

})

这是你需要读的,看看吧。但还是很困惑。我这里的问题是,$:checkbox.click不会执行。但是如果我把它放在第一个ajax的回调成功函数中,它可以工作,但只能工作一次。我需要的复选框可以调用触发点击功能…delagation似乎有一个先决条件,即DOM元素必须首先存在??但是复选框只出现在第一个ajax之后……关键是委托在不存在的元素上工作。将其更改为$document。在“单击”时,边栏li>a',函数e。。。因为文档总是存在的。哇…酷…我会试试这个。昨天我用了愚蠢的方法将复选框“点击”改为“点击”,因为div总是存在的。谢谢你,罗伯!!