Load more buttons doesn't work with some fields like entity_reference (field_tags). To solve this using the classes that are a common among fields.

Comments

xangy created an issue. See original summary.

xangy’s picture

StatusFileSize
new3.65 KB

Used '.field__items .element-invisible' instead of '.field__item.element-invisible'. Plus did code cleanup.

xangy’s picture

Assigned: xangy » Unassigned
Status: Active » Needs review
gg24’s picture

Status: Needs review » Needs work
  1. +++ b/css/loader.css
    @@ -1,3 +1,3 @@
    \ No newline at end of file
    

    Add a new line in the last.

  2. +++ b/field_load_more.libraries.yml
    @@ -5,4 +5,6 @@ loader:
    \ No newline at end of file
    

    Add a new line in the last.

  3. +++ b/field_load_more.module
    @@ -108,9 +102,9 @@ function field_load_more_preprocess_field(&$variables) {
    \ No newline at end of file
    

    Add a new line in the last.

  4. +++ b/js/loader.js
    @@ -23,4 +23,4 @@
    \ No newline at end of file
    

    Add a new line in the last.

xangy’s picture

Assigned: Unassigned » xangy
xangy’s picture

Assigned: xangy » Unassigned
Status: Needs work » Needs review

@gg24, tested patch #2 on fresh git clone. It applies cleanly and adds the new line at the end of files where it was, earlier, missing.

krina.addweb’s picture

Status: Needs review » Needs work
StatusFileSize
new27.79 KB

Hi xangy,

Thanks! for the patch, But i think after load all field values load more button should be disabled , As it is confusing for end user that all values were already loaded or not.

xangy’s picture

Assigned: Unassigned » xangy
Issue summary: View changes
Status: Needs work » Active

Thanks, krina.addweb for the review. working on it now.

xangy’s picture

Issue summary: View changes
nrackleff’s picture

In my case, the patch applied to the dev version of the module, but it did not fix the problem. It does only load the three (as per setting), but when I click the 'load more' button/link, the 'element-invisible' class is not removed from the hidden items. The button does disappear once it thinks it has made all of the content visible. I do not see any javascript errors. It just doesn't remove the class.

It works if I change:
$('.field__items .element-invisible', $parentFieldWrapper).each(function() {
back to:
$('.field__item.element-invisible', $parentFieldWrapper).each(function() {

glynster’s picture

Very easy fix everyone. The below class just needs to be updated

field__item -> field--item

sharique’s picture

Version: 8.x-1.x-dev » 8.x-2.0

Patch needs reroll for 2.x branch.

sharique’s picture

StatusFileSize
new3.25 KB

Update patch for 2.0 release.

sharique’s picture

Status: Active » Needs review
xangy’s picture

Assigned: xangy » Unassigned