jqModal не работает
Я пытался протестировать некоторый рабочий код с http://dev.iceburg.net/jquery/jqModal/ чтобы понять, как это работает, но я не могу заставить код работать. Я пытаюсь использовать часть всплывающего диалогового окна, и я тестирую код по умолчанию, который является первым примером, в разделе примеров. вот что я скопировал и попробовал проверить. часть, которая не работает, является диалоговым окном, появляющимся. я получаю сообщение об ошибке, скажем.... Uncaught ReferenceError: $ не определено
<html>
<head>
<title> test </title>
<style type = "text/css">
.jqmWindow {
display:none;
position: fixed;
top: 17%;
left: 50%;
margin-left: -300px;
width: 600px;
background-color: #EEE;
color: #333;
border: 1px solid black;
padding: 12px;
}
.jqmOverlay { background-color: #000; }
# html .jqmWindow {
position: absolute;
top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');
}
</style>
<script type = "text/javascript">
$().ready(function() {
$('#dialog').jqm();
});
</script>
</head>
<body>
<a href="#" class="jqModal">view</a>
...
<div class="jqmWindow" id="dialog">
<a href="#" class="jqmClose">Close</a>
<hr>
<em>READ ME</em> -->
This is a "vanilla plain" jqModal window. Behavior and appeareance extend far beyond this.
The demonstrations on this page will show off a few possibilites. I recommend walking
through each one to get an understanding of jqModal <em>before</em> using it.
<br /><br />
You can view the sourcecode of examples by clicking the Javascript, CSS, and HTML tabs.
Be sure to checkout the <a href="README">documentation</a> too!
<br /><br />
<em>NOTE</em>; You can close windows by clicking the tinted background known as the "overlay".
Clicking the overlay will have no effect if the "modal" parameter is passed, or if the
overlay is disabled.
</div>
</body>
</html>
1 ответ
Если ваш код действительно является вашим HTML, то причина, по которой $ не определен, состоит в том, что вы не включили jQuery (который определяет $ и часто использует его для краткости). Ваш код не включает ни библиотеку jQuery, ни скрипт jqModal. (Следует признать, что все примеры на сайте jqModal являются выдержками, а не полным кодом, поэтому они принимают этот шаг как должное.)
добавлять
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="/assets/js/jqModal.js"></script>
в вашем <head>
, корректируя путь для jQModal.js в зависимости от ситуации.