1rosehip / jplist-es6

jPList is a JavaScript library for sorting, pagination and filtering of any HTML structure like DIVs, UL/LI, tables, etc.
https://www.jplist.org/
MIT License
83 stars 39 forks source link

How to initialize a plugin through a es6? #21

Closed 12evgen closed 6 years ago

12evgen commented 6 years ago

First of all, I want to express my gratitude for your excellent work, this plugin does not really have competitors in its functionality. I have some questions.

  1. When will it be possible to download this plug-in via npm?
  2. And how can I initialize the plugin if I want to connect it as a module ES6?
1rosehip commented 6 years ago

Hi, Thank you for the feedback, I'm glad that the plugin is useful for you.

  1. I've uploaded the lib to npm, it's accessible here: https://www.npmjs.com/package/jplist-es6
  2. There is an ES6 jplist version here: https://github.com/1rosehip/jplist-es6/blob/master/dist/1.2.0/jplist-es6.min.js Also it's possible to import index.js or jplist.js as entry point in your source files depending on your needs.
12evgen commented 6 years ago

Hi! thanks for the help! I connected the plugin as a module. Is it possible to call Jplist through the constructor (as indicated in the picture)?

jplist

The following error in the console

jplist-3

1rosehip commented 6 years ago

There is some required code that should be added before jplist initialization, you may find it in index.js. jPList requires window.jplist.controlTypes that actually just a ES6 Map of controls that you need in your app. In the index.js file above there is a full list of controls, but you may include only controls that you need.

Also index.js contains custom events polyfill for IE 10/11, without it jPList won't work in these browsers.

And the last important thing is binding to jPList APIs:

window.jplist.init = jplist.init.bind(jplist);
window.jplist.refresh = jplist.refresh.bind(jplist);
window.jplist.resetControls = jplist.resetControls.bind(jplist);
window.jplist.resetControl = jplist.resetControl.bind(jplist);
amrography commented 4 years ago

@12evgen try import "jplist-es6/dist/1.2.0/jplist-es6.min.js";