2

My simple jQuery dialog isn't working with cakephp.

My default ctp is:

<head>
<?php echo $this->Html->charset(); ?>
<title>
    <?php echo $cakeDescription ?>:
    <?php echo $title_for_layout; ?>
</title>

<?php
    echo $this->Html->meta('icon');

    echo $this->Html->css('cake.generic');

    echo $this->Html->script('http://code.jquery.com/jquery-1.8.2.js');
    echo $this->Html->script('test');
    echo $this->fetch('meta');
    echo $this->fetch('css');
    echo $this->fetch('script');
?></head>

That output this:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script><script type="text/javascript" src="/cake/js/test.js"></script>

The test.js already inside the 'js' folder:

$(function() {
    $( "#dialog" ).dialog();
});

And paginateste.ctp

<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p></div>

Can someone help me? thanks...

3
  • 1
    any errors outputing in the console? have you tried changing $ -> jQuery? Commented Oct 30, 2012 at 14:55
  • Wrap it inside $(document).ready(). I believe it's executing the script and the page isn't finished loading. Or you could put the test.js at the bottom of the page. Commented Oct 30, 2012 at 14:56
  • 1
    .dialog isn't part of basic jQuery; you need jQuery-UI as well. Commented Oct 30, 2012 at 14:58

1 Answer 1

1

Remember to include the applicable jquery-ui.js and jquery-ui.css!

Working fiddle here:

Sign up to request clarification or add additional context in comments.

Comments

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.