WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] jQuery Modal within a Plugin (2 posts)

  1. mikeill
    Member
    Posted 4 months ago #

    The following code works great outside of wordpress, but within wordpress plugin it seems to be reading the "target" as an expression; "unrecognized expression").

    jQuery(document).ready(function($) {
    $("a[data-target=#myModal]").click(function(ev) {
        ev.preventDefault();
        var target = $(this).attr("href");
        // load the url and show modal on success
        $("#myModal").load(target, function() {
        window.alert(target);
             $("#myModal").modal({show:true});
        });
    });
    });
  2. mikeill
    Member
    Posted 4 months ago #

    the problem was that I had forgotten to urlencode() the variables within the href. Which ends up looking like this:

    /inc/modal_descriptions.php?classDescription=<?php echo urlencode(substr($classDescription, 0, 1000)) ?>"> <?php echo $className ?>

Reply

You must log in to post.

About this Topic