我想使用jquery easyui提供的函数触发一个弹出框, 代码如下,它不是触发器:当我点击打开时,没有打开弹出框, 弹出框元素也没有隐藏,它应该像我按照他们的教程材料一样工作。谢谢
代码:
头部提取物:
<script>
$(function(){
$('#win').window('open');
});
</script>
身体:提取物:
<button onclick="javascript:$('#win').window('open')"> Permission Settings</button>
<div id="win" class="easyui-window" closed="true" title="Login" style="width:300px;height:180px;">
<form style="padding:10px 20px 10px 40px;">
<p>Name: <input type="text"></p>
<p>Pass: <input type="password"></p>
<div style="padding:5px;text-align:center;">
<a href="#" class="easyui-linkbutton" icon="icon-ok">Ok</a>
<a href="#" class="easyui-linkbutton" icon="icon-cancel">Cancel</a>
</div>
</form>
</div>
整个部分:
<?
include("../connection/conn.php");
session_start();
if($_SERVER['REQUEST_METHOD'] == "POST"){
if (!isset($_POST['subscribe']))
$_POST['subscribe']=0;
if (!isset($_POST['unsubscribe']))
$_POST['unsubscribe']=0;
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$listName = $_POST['lname'];
$listFromName = $_POST['fname'];
$listReplyTo = $_POST['remail'];
$listSubject = $_POST['sub'];
$listRemindSub = $_POST['subscribe'];
$listRemindUnSub = $_POST['unsubscribe'];
$listReminder = $_POST['creminder'];
$query="INSERT INTO list (ListID,ListName,FromName,ReplyTo,Subject,IsRemindSub,IsRemindUnSub,CreateDate,Reminder) VALUES ('',?,?,?,?,?,?,CURDATE(),?)";
$stmt = $conn->prepare($query);
$stmt->bindParam(1, $listName , PDO::PARAM_STR);
$stmt->bindParam(2, $listFromName, PDO::PARAM_STR);
$stmt->bindParam(3, $listReplyTo, PDO::PARAM_STR);
$stmt->bindParam(4, $listSubject, PDO::PARAM_STR);
$stmt->bindParam(5, $listRemindSub, PDO::PARAM_INT);
$stmt->bindParam(6, $listRemindUnSub, PDO::PARAM_INT);
$stmt->bindParam(7, $listReminder, PDO::PARAM_STR);
$stmt->execute();
}
catch(PDOException $e)
{
die ($e->getMessage().'<a href="add.php"> Back</a>');
$conn->rollBack();
}
try {
$lastID=$conn->lastInsertId();
$query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'Email','{email}')";
$stmt = $conn->prepare($query);
$stmt->execute();
$query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'FirstName','{fname}')";
$stmt = $conn->prepare($query);
$stmt->execute();
$query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'LastName','{lname}')";
$stmt = $conn->prepare($query);
$stmt->execute();
}
catch(PDOException $e)
{
die ($e->getMessage().'<a href="add.php"> Back</a>');
$conn->rollBack();
}
try {
$userID = $_SESSION['username'];
$query="INSERT INTO user_list (UserID,ListID,UserListRights) VALUES (?,$lastID,'Edit')";
$stmt = $conn->prepare($query);
$stmt->bindParam(1, $userID, PDO::PARAM_STR);
$stmt->execute();
}
catch(PDOException $e)
{
die ($e->getMessage().'<a href="add.php"> Back</a>');
$conn->rollBack();
}
$conn = null;
?>
<div id="stylized" class="myform">
<div style="text-align:center;font-weight:bold;">You have created a list. By default Mail Address, First Name , Last Name is in your list. Add more field if you want. <a href='add.php'>Back</a></div>
<div class="spacer"></div>
</div>
<?
}else{?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../style/form.css" />
<script type="text/javascript" src="../plugin/easyui/jquery.easyui.min.js"></script>
<script src="../plugin/jquery-1.6.1.min.js"></script>
<script src="../plugin/jquery.validate.min.js"></script>
<script src="../plugin/jquery.form.js"></script>
<script>
$(document).ready(
function(){
$("#addlist").validate();
});
</script>
<script>
$(function(){
$('#win').window('open');
});
</script>
</head>
<body>
<div id="stylized" class="myform">
<form id="addlist" method="post" action="add.php" >
<h1>Create your new subscriber list</h1>
<p>Create a new list before adding subscriber <label class="right"><em class="dot">*</em> indicates required</label></p>
<label><em class="dot">*</em> List name:
<span class="small">Add your list name</span>
</label>
<input id="lname" name="lname" class="required" />
<div class="spacer"></div>
<label>Reminder:
<span class="small">Remind the details of your list</span>
</label>
<textarea id="creminder" name="creminder" cols="52" ></textarea>
<div class="spacer"></div>
<p>Permission Setting ...</p>
<label>Open to other users:</label> <input type="checkbox" class="checkbox" name="public" value="1">
Or
<div class="spacer"></div>
<button onclick="javascript:$('#win').window('open')"> Permission Settings</button>
<div id="win" class="easyui-window" closed="true" title="Login" style="width:300px;height:180px;">
<p>Name: <input type="text"></p>
<p>Pass: <input type="password"></p>
<div style="padding:5px;text-align:center;">
<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="javascript:alert('save')">Save</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dd').dialog('close')">Close</a>
</div>
</div>
<div class="spacer"></div>
<p>Email me when ...</p>
<label>People subscribe:</label> <input type="checkbox" class="checkbox" name="subscribe" value="1">
<div class="spacer"></div>
<label>People unsubscribe:</label> <input type="checkbox" class="checkbox" name="unsubscribe" value="1">
<div class="spacer"></div>
<input class="submit" type="submit" name="submit" value="Submit"/>
<div class="spacer"></div>
</form>
<div class="spacer"></div>
</div>
<br><br><br>
<div id="stylized" class="myform">
<?
try{
$sql = '
SELECT *
FROM list,user_list
WHERE user_list.UserID=?
AND list.ListID=user_list.ListID
';
$stmt = $conn->prepare($sql);
$stmt->execute(array($_SESSION['username']));
$result= $stmt->fetchAll();
$num_rows= $stmt->rowCount();
}
catch(PDOException $e)
{
die ($e->getMessage().'<a href="add.php"> Back</a>');
}
$conn = null;
if ($num_rows == 0) {
echo '<div style="text-align:center;font-weight:bold;">You have not created any list yet.</div>';}
else {
echo '<h1>Your Subscriber List</h1> <p>You have created '.$num_rows.' list(s).</p>';
foreach ($result as $set)
{
echo '<div style="font-weight:bold;">List Name : '.$set['FromName'].'</div><br>';
echo '<div style="font-weight:bold;">Subscriber : </div><br>';
echo '<div style="font-weight:bold;">Create Date : '.$set['CreateDate'].'</div><br>';
echo '<hr>';
}}
?>
<div class="spacer"></div>
</div>
</body>
</html>
<?
}
?>
答案 0 :(得分:1)
将脚本更改为此顺序:
<link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../plugin/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../style/form.css" />
<script src="../plugin/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="../plugin/easyui/jquery.easyui.min.js"></script>
<script src="../plugin/jquery.validate.min.js"></script>
<script src="../plugin/jquery.form.js"></script>
所以插件出现在jQuery脚本之后。
答案 1 :(得分:0)
乍一看,脚本引用的顺序不正确:您需要先引用jQuery然后再引用jQuery EasyUI:
<script src="../plugin/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="../plugin/easyui/jquery.easyui.min.js"></script>