Skip to content

TypeError: templateInstance.collection.findOne is not a function( with FS collection ) #578

Closed
@michelkeyaerts

Description

@michelkeyaerts

Hello,
I want to use Sortable on images with a FS collection. For now, drag and drop works only once and I have an error in the console: TypeError: templateInstance.collection.findOne is not a function ( rubaxa_sortable.js:1333:20)
How can I fix it?
I have a FS collection:

Images = new FS.Collection("images", {
  stores: [ 
    new FS.Store.FileSystem("images"),
    new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }),
  ],
  filter: {
    allow: {
      contentTypes: ['image/*'] //allow only images in this FS.Collection
    }
  }
});

In sortable-collection.js (server side)

'use strict';
Sortable.collections = ['images'];
//I also tried  Sortable.collections = ['cfs.images.filerecord'];

In the template portfolio.html:

 {{#sortable items= imagesCursor sortField="metadata.order"}}  
             <img src="{{this.url  store='thumbs'}}" alt="caption for {{this.name}}" target="{{this}}" />
  {{/sortable}}

And in the portfolio.js helper imagesCursor function

      var result = Images.find({  'metadata.gallery':currentGallery});  // Images is an FS.Collection instance 
      return result;

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