无法将jquery添加到魅力中(Having trouble adding jquery to charisma)

我正在尝试为这个魅力管理面板添加一些jquery,并且一直没有麻烦。 我想将它添加到charisma.js文件中。 这就是我要补充的内容

// add multiple select / deselect functionality $("#selectall").click(function () { $('.checkbox').attr('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa $(".checkbox").click(function(){ if($(".checkbox").length == $(".checkbox:checked").length) { $("#selectall").attr("checked", "checked"); } else { $("#selectall").removeAttr("checked"); } });

我已经尝试过这个代码包含在匿名$(function(){以及没有,我已经将它插入到$(document).ready(function(){和docReady()以及我的head代码,但我没有真正“训练”jquery所以我有点迷失我的错误。我的class和div标签对于代码是正确的,因为我已经多次检查它们的拼写错误。我不确定我做错了什么。有没有更好的“检查”我可以在这里使用的所有代码,或者我只是把这一切都放在错误的地方?

更新:我认为实际的代码可能正常工作,我不知道,在我点击全部选中框后,似乎我必须单击其他框3次才能将复选标记放回到框中,所以看起来好像是实际上显示盒子已标记有问题。 这可能是样式的问题,但我不知道如何纠正它。

I am trying to add some jquery to this Charisma admin panel and have been having nothing but trouble. I am trying to add it to the charisma.js file. This is what I am adding

// add multiple select / deselect functionality $("#selectall").click(function () { $('.checkbox').attr('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa $(".checkbox").click(function(){ if($(".checkbox").length == $(".checkbox:checked").length) { $("#selectall").attr("checked", "checked"); } else { $("#selectall").removeAttr("checked"); } });

I have tried this code wrapped in the anonymous $(function(){ as well as without, and I have inserted it into both $(document).ready(function(){ and docReady() as well as in the head of my code but I am not really "trained" on jquery so I am a bit lost as to what I am doing wrong. My class and div tags are correct for the code, as I have checked them several times for misspellings. I am not sure what I am doing wrong. Is there a better "check" all code I can use here, or am I just putting this all in the wrong place?

UPDATE: I think the actual code may be working, I cannot tell, after I click the select all box it seems that I have to click the other boxes 3 times to get the check mark back into the box, so it seems like it is having trouble actually showing that the box is marked. This may be a problem with styling, but I don't know how to correct it.

最满意答案

我遇到了和你一样的问题。 我的解决方案是这样的:

找到这条线“

$("input:checkbox,input:radio, input:file").not('[data-no-uniform="true"],#uniform-is-ajax').uniform();"

然后,删除input:checkbox,然后项目中的复选框将不会以魅力方式显示。现在你可以使用$(this).prop("checked","checked"); 使复选框更改。

I meet the same problem as you do. My solution is like this:

find the line "

$("input:checkbox,input:radio, input:file").not('[data-no-uniform="true"],#uniform-is-ajax').uniform();"

then,remove the input:checkbox, then the checkbox in your project will not display in the charisma way.Now you can use $(this).prop("checked","checked"); to make the checkbox change.

更多推荐