javve / list.pagination.js

A pagination plugin for List.js
24 stars 23 forks source link

Can't figure out how to use plugin with Brunch/CommonJS #3

Closed dagjomar closed 10 years ago

dagjomar commented 10 years ago

This worked fine with 0.2 release

Trying to implement 1.0 release, but can't figure out how to get plugin working in the CommonJS module environment.

This is a test file I have. app.js contains all the compiled CommonJS modules.

    <script src="/javascripts/app.js"></script>

    <div id="hacker-list">
        <ul class="list"></ul>
    </div>

    <script>

    var List = require('modules/IARegionList/list');
    var ListPagination = require('modules/IARegionList/list.pagination');

    var options = {
        item: '<li><h3 class="name"></h3><p class="city"></p></li>',
        plugins: [ ListPagination() ]
    };

    var values = [
        { name: 'Jonny', city:'Stockholm' }
        , { name: 'Jonas', city:'Berlin' }
    ];

    var hackerList = new List('hacker-list', options, values);
        $(function(){

    });

what I get from the console is an error in list.pagination.js Uncaught TypeError: Cannot read property 'childNodes' of undefined list.js:1336

javve commented 10 years ago

In this example you do not have a container for the pagination. <ul class="pagination"></ul>

dagjomar commented 10 years ago

Thanks. That was part of the problem.

Also, had to make sure that the list.pagination.js knew about the list.js file, as it is not in Global space and "List" was undefined.

var List = require("modules/IARegionList/list");