WordPress.org

Ready to get started?Download WordPress

Forums

SimpleModal Login
Call simplemodal-login from another plugin (5 posts)

  1. gambinaut
    Member
    Posted 1 year ago #

    Hi Eric,

    First, I'd like to thank you for creating simplemodal login. Right now I'm using version 1.0.6, and it's a great plugin. I just have a one question: how can I run simple modal login from inside a plugin that I'm developing? I've seen various threads that have asked similar questions, and none of the solutions in those threads have worked for me. I'd imagine that this is because simplemodal login has changed in the past year.

    I've tried variations of this:
    $('.simplemodal-login').trigger('click.simplemodal-login');

    but nothing happens. I'm otherwise able to use javascript in my plugin, but for some reason that code doesn't seem to run simplemodal login. Do you know of some other way I can call simplemodal-login from my plugin? I apologize in advance if I'm making some obvious mistake - I'm very new to wordpress, PHP, and javascript. Anyway, thanks!

    http://wordpress.org/extend/plugins/simplemodal-login/

  2. totels
    Member
    Posted 1 year ago #

    $('.simplemodal-login').click()
    $('.simplemodal-login').trigger('click')
    $('.simplemodal-login').trigger('click.simplemodal-login')

    All work for me, you may have a context issue if you are trying to call it from someplace where jQuery or SimpleModal are not yet loaded.

  3. gambinaut
    Member
    Posted 1 year ago #

    You're probably right. If there is a context issue, how would I address it?

    I apologize if these questions seem trivial - I'm very new to coding in PHP and javascript and using wordpress.

  4. gambinaut
    Member
    Posted 1 year ago #

    This was my naive solution to the context issue, which didn't work:

    $(document).ready(function () {
    $(\.simplemodal-login\').trigger(\click\')
    });

    Does simplemodal-login load last or something along those lines?

  5. totels
    Member
    Posted 1 year ago #

    If you can't call it from a document ready it's possibly something else not loading at all. I find that my best friend is console.log(<data>).

    For this particular problem though, you should be able to just open up a browser console and use it directly to see if things are loaded as you expect. It's also possible you don't have jQuery mapped to $ correctly.

    (function($) {
        $('.simplemodel-login').trigger('click');
    })(jQuery);

    might be a better test.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic