Skip to content

TypeError: templateInstance.collection.findOne is not a function #8

Open

Description

@jdmswong

Same problem as: SortableJS/Sortable#768

My manifestation of the problem:
screen shot 2016-04-04 at 11 17 41 am

caused by dragging and reordering an image

My code:
in template

                    {{#sortable items=images}}
                        <img class="gallery-img thumbnail" src="{{this.fname}}">
                    {{/sortable}}

in helper

        return GalleryPhotos.find(
            {
                'gallery_id': myId
            },
            {
                sort: ['order']
            }
        ).fetch();

Activity

  1. dylanmcgowan commented on Apr 6, 2016

    @dylanmcgowan

    I'm also getting this error... Would love a fix

  2. mikepaszkiewicz commented on Apr 6, 2016

    @mikepaszkiewicz

    @jdmswong @dylanmcgowan Try removing the .fetch() - solved the problem for me.

    When using fetch, it assigns templateInstance.collection to a typical collection fetch [ {}, {}, ...]
    In reality, the package is looking for a cursor to do a findOne on the changed document's collection.

    // line 1405 rubaxa_sortable.js
    var startOrder = templateInstance.collection.findOne(itemId)[orderField];      
    // 
    

    Could have sworn that fetch() has worked in the past, who knows though. The package got moved and isn't actively maintained, so not sure if any behavior was changed before the move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions