• Resolved heather.m

    (@heatherm-1)


    Hello,

    Thanks for the great plugin! I’m currently setting up a site using WordPress as a CMS, and streamlining table creation/editing is really going to help with maintenance. I am having one issue though. Elsewhere on the site, I’m using MooTools. Whenever I activate the additional js libraries for your plugin (datatables, etc) it conflicts with the mootools applications. If I deactivate the js libraries, the problem goes away and the rest of the plugin works fine. I’ve tried switching which library is in use, with no results. I’ve even opened up the jquery files for each of those libraries and tried to set them in no-conflict mode, but no success.

    I really love how WP-Table Reloaded works, so if I need to leave off the extra functionality to use it I will. But table sorting and searching would be nice if I could get it to play nice with my mootools. Any help would be great.

    -Heather

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for the nice comment about tables!

    And I’m sorry that you are experiencing conflicts with the JS library. Unfortunately I don’t know their internals, as I didn’t develop them, so I have no clue what conflicts in them or how it could be fixed.

    Have you tried all three libraries that come with the plugin?

    If neither works, it’s probably the best to contact the author of DataTables in the forums at http://www.datatables.net/

    Thanks!
    Tobias

    Thread Starter heather.m

    (@heatherm-1)

    Thanks for the quick response! I did try all 3, but had the same problem. I’ll probably take your advice and ask the DataTables author. When I was looking through the forums yesterday, I found old posts regarding earlier versions where people were having similar issues, and he said that he often forgets to set his code in no-conflict mode. Maybe that’s the problem. If I figure it out I’ll post it here in case someone else runs into the same problems. Thanks again for all your help!

    Thread Starter heather.m

    (@heatherm-1)

    In case anyone else is interested…
    On closer inspection I found where the problem comes in, but have no clue how to fix it. The js libraries are set in no conflict mode already, so no worries on that front. When the libraries are activated, the plugin is somehow loading jquery before mootools. I don’t really have experience in all this, it’s been learn as I go (yikes!), but I’ve found that my mootools usage breaks unless mootools is loaded first, then jquery. After messing around with it for a while and doing a lot of research, I’ve got nothing. So I’ll just use the tables w/o the libraries. But I figured I’d post what I found here in case someone else ever needs it – as a jump start of sorts 🙂
    – Heather

    Thread Starter heather.m

    (@heatherm-1)

    Alas! I figured it out! In case anyone else has this problem (which seems unlikely), I’m posting the solution.

    Turns out that the problem was how I had enqueued my scripts. Being a newbie, I didn’t set up my functions file properly. I discovered this when working through some other issues later. After finally getting that sorted out yesterday, today I remembered the problems I had with the js libraries for this plugin. I just tested them out and all is well now. Yay!

    Here’s the magical code:

    <?php
    function my_mootools() {
        if (is_page('home')) {
            wp_register_script('mootools', '/wp-content/themes/my-theme-name/js/mootools-1.2-core.js', false, '1.2.0');
            wp_enqueue_script('mootools');
            wp_deregister_script('jquery');
            wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', array('mootools'));
        }
    }
    add_action('wp_print_scripts', 'my_mootools');
    ?>
    <?php
    function my_jquery_not_home() {
        if (!is_page('home')) {
            wp_deregister_script('jquery');
            wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');
        }
    }
    add_action('wp_print_scripts', 'my_jquery_not_home');
    ?>

    I was only using the mootools for a something specific on the home page (probly a frivolous use of a separate library, i know. but i really couldn’t get what i needed from any jquery plugins). At any rate, there are now 2 php functions above, the first is to enqueue both the mootools and jquery on the home page only. The key to making the js libraries for this plugin work lies in that first function. By setting the array on jquery to ‘mootools’, mootools now loads first. Fancy that! It’s in the codex, but somehow, I never paid it attention. Now everything is great!

    Sidepoint: In case you were wondering, the 2nd function is to set jquery for every other page besides home. I had tried making the jquery line separate from the ‘my-mootools’ function, with the array to load mootools 1st. Unfortunately, the array also means jquery will not load at all unless mootools loads. Since I was only loading it on the home page, the rest of the site was losing jquery. By setting 2 functions, 1 for home and 1 for not home, I get to separate mootools from the rest of the site w/o losing jquery (so every page of my site no longer has to load a heavy js library that isn’t being used, speeding things up a bit).

    Hope this helps someone save a lot of time one day 🙂

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Heather,

    thanks for your feedback, hopefully this will be helpful to other people!

    I can indeed imagine that including MooTools and jQuery at the same time caused a conflict, because both use similar function names as far as I know.

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP-Table Reloaded] JS Libraries conflict with Mootools’ is closed to new replies.