Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jdmswong opened this issue Apr 4, 2016 · 2 comments
Open

Comments

@jdmswong
Copy link

jdmswong commented Apr 4, 2016

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();
@dylanmcgowan
Copy link

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

@mikepaszkiewicz
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants