Problem

Nested checkboxes don't work well with jQuery 1.6+ due to prop and attr changes http://api.jquery.com/prop/

  • Hit parent item
  • Children items won't be ticked off automatically
  • Tick off all children items
  • Parent item won't be ticked off automatically
  • Uncheck one of a children items
  • Parent item won't populate proper checked/unchecked state

Solution

Add helper functions to detect jQuery version and upgrade code to reflect this change. Patch is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cr0ss’s picture

Update patch. Major fix is removing .has('ul') from nested checkboxes. Since there could be a parent item without children and it still have to fire submit behavior.

knalstaaf’s picture

Status: Active » Needs review

Seems to do the job for me!

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

@knalstaaf if you are using the patch and it is working for you then you can change the status to 'Reviewed & tested by the community'. It's working for me too - changing status :)

mikeker’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, just had time for a super quick visual review and haven't tested this patch yet.

  1. +++ b/better_exposed_filters.js
    @@ -372,6 +374,42 @@
    +   * @return false - when version is
    

    Nitpick: missing "not" or "is less than or equal to 1.6". Also "the" before "version" in this line and the line above.

  2. +++ b/better_exposed_filters.js
    @@ -372,6 +374,42 @@
    +  function _bef_jquery_version() {
    

    I would prefer to name this differently since it's not returning the version of jQuery but a bool.

  3. +++ b/better_exposed_filters.js
    @@ -372,6 +374,42 @@
    +    console.log(elem);
    

    Leftover debug code?

  4. +++ b/better_exposed_filters.js
    @@ -372,6 +374,42 @@
    +    if (_bef_jquery_version()) {
    +      elem.prop('checked', checked);
    +    }
    

    Don't we need an else clause?

Neslee Canil Pinto’s picture

Status: Needs work » Closed (won't fix)

Hi, there will be no more future development for 7.x branch. If you see this issue in 8.x, feel free to file an issue. Closing this as Closed(wont fix).