0

I have a custom template page I'm building for a wordpress site (using a modified Twenty Eleven theme). In the page there are links that are created programmaticly. There will be several links such as this:

<a href="http://www.site.com.com/info.php?id=123" class="uimodal">More Information</a>

I would like any URL with the class of uimodal to come up in a jQuery UI modal window (dialog) but I'm having problems getting it to do so.

I've successfully loaded jQuery UI. I have tried several code snippets online, not getting any errors via Firebug, it just doesn't load modal (just replaces the current page).

Any help is appreciated!

Thanks.

1 Answer 1

1

Try something like this: http://jsfiddle.net/hSRdr/

$(function() { // same as $(document.ready(function() {
    $('a.uimodal').on('click', function() {
        var href = $(this).attr('href');

        $('<div>').append('<iframe src="' + href + '"></iframe>').dialog();
        return false;
    });
});
Sign up to request clarification or add additional context in comments.

3 Comments

This must be a WP problem, because your fiddle is obviously working but it wont work when I take it into WP
Is it wrapped inside $(document).ready()? I've updated my answer to include that.
Yes but I think its a wordpress problem. I know with wordpress you can't use $(document) you must use jQuery(document) so I think its just something there. I know your answer works so I've marked it as such. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.