Need help figuring out how to utilize sort library


#1

I’m new to Meteor and Javascript.

I’m trying to implement the sort library found here:

https://github.com/RubaXa/Sortable/tree/master/meteor

I know this is probably simple, but the simpliest invocation of the code here: {{sortable <collection|cursor|array>}}

still leaves me a bit baffled. I’ve tried passing collections like:

{{sortable PlayersList}} but, have no idea what the output is supposed to be, or how I am supposed to handle it.

I learn by example, can someone help me out by showing me how to use the simpliest implementation of the library?

This is my first time posting on a forum in a long time. I usually can Google-Fu my way around.

Thanks!


#3

I figured it would help if I included my code.

<head>
  <title>sortof</title>
</head>

<body>
  <h1>Welcome to Meteor!</h1>

  {{> hello}}
</body>

<template name="hello">
  
   Unsorted:
  {{#each showplayers}}
    
    <li>{{name}}: {{score}}</li>
  
  {{/each}}

  
  Sorted:
  
  {{#sortable showplayers}}
    
    <li>{{name}}: {{score}}</li>
  
  {{/sortable}}
  
 


</template>

Output:

Welcome to Meteor!

Unsorted:
Bob: 0
Larry: 0
Henry: 0
Sorted:


#4

Added meteorpad for reference here: http://meteorpad.com/pad/bTef4LYPLLNFS7Jdd/Xamtest


#5

Removed the {{#each name}} block and worked for me http://meteorpad.com/pad/GvG64pxECBdfxeHRR/Copy%20of%20Xamtest


#6

You rock. Thanks! I’ve been banging my head trying to get it to work.


#7

You’re welcome, have fun :grin: