0

We are using Ember with Semantic-UI. We are trying to get a sortable table (https://semantic-ui.com/collections/table.html#sortable).

We installed the kylefox jquery plugin with npm install jquery-tablesort

our .hbs file has the following included:

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="jquery.tablesort.js"></script> 
<script>  
$(document).ready(function() {
     $('table').tablesort();
});
</script>

But I get the following in the console:

jquery.js:3869 Uncaught TypeError: $(...).tablesort is not a function

Is there anything we forgot to include?

Gennady Dogaev
  • 5,902
  • 1
  • 15
  • 23
Andreas Sauer
  • 1,407
  • 2
  • 8
  • 6
  • Make sure `jquery.tablesort.js` file actually exists and path is correct. – unalignedmemoryaccess Apr 13 '17 at 08:55
  • We created a jquery.tablesort.js file which has the following code (https://semantic-ui.com/javascript/library/tablesort.js) in the same directory as our .hbs file.¯\_(ツ)_/¯ – Andreas Sauer Apr 13 '17 at 11:46
  • Easiest way to test if browser see the directory is to open source code in browser and click on link for tablesort lib. – unalignedmemoryaccess Apr 13 '17 at 11:48
  • In the source code there is missing the jquery.tablesort.js indeed... However I placed it in my public, I placed it in the .hbs file, I imported it in the index.html but it is no recognized – Andreas Sauer Apr 13 '17 at 12:55
  • What is .hbs file? If it is template, that does not mean that it is directly in root dir. In most cases it is not. Put `.js` file inside root www folder (where main `index.php` or any other root file is located. – unalignedmemoryaccess Apr 13 '17 at 12:56
  • Some resources to help you: http://stackoverflow.com/questions/24727503/how-to-add-date-picker-or-any-general-jquery-plugin-to-ember-cli-app, https://guides.emberjs.com/v2.12.0/components/the-component-lifecycle/#toc_integrating-with-third-party-libraries-with-code-didinsertelement-code, https://guides.emberjs.com/v2.12.0/applications/initializers/ – Jeremie Ges Apr 14 '17 at 04:23

1 Answers1

0

First, read ember-cli guide. It explains how to manage dependencies and you doing it completely wrong.

Then read ember guide and try to understand how to use components, because that's the only reliable way to use jquery plugins with ember.

Gennady Dogaev
  • 5,902
  • 1
  • 15
  • 23