Arm*_*man 9 jquery modal-dialog twitter-bootstrap jquery-events
我正在研究"添加链接"功能.为此,我正在使用Twitter Boostrap JS的Modal插件.在主页面上只有要填充的"链接"字段,当用户点击"添加链接"按钮时,会弹出一个模式,用户会看到完整的表单以填充3个字段:链接,标题,标签.但是,我希望链接字段预先填充上一步的值.它与您在delicious.com上保存链接时发生的情况类似.
感谢Joe的帮助(上一个问题)我可以在模态对话框上打印linkURL,但重要的是此linkURL是带有3个字段(链接,标题,标签)的表单的链接字段的值.知道如何做到这一点?谢谢!
<html>
<head>
<title>Example</title>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap-modal.js"></script>
<link rel="stylesheet" href="scripts/bootstrap.min.css">
<link rel="stylesheet" href="main.css" />
<script type="text/javascript">
$(document).ready(function()
{
$('#modal-from-dom').bind('show',function()
{
$(".modal-body").html($("#linkURL").val());
});
});
</script>
</head>
<body>
<!-- The Modal Dialog -->
<div id="modal-from-dom" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Add Link</h3>
</div>
<div class="modal-body">
<!--
<form id='post-on-wall' method='POST' action='savePost.php' enctype='multipart/form-data'>"
<input type='text' class='label-inline' name='linkURL' id='wall-post' value=linkURL>
</form>
-->
</div>
<div class="modal-footer">
<a href="#" class="btn primary">Add Link</a>
</div>
</div>
<div class="container">
<div class="wall-post">
<textarea class='label-inline' name='linkURL' id='linkURL'></textarea>
<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true" class="btn">Add Link</button>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
Mar*_*sen 10
$('#modal-from-dom').bind('show',function()
{
$(".modal-body #wall-post").val($("#linkURL").val());
});
Run Code Online (Sandbox Code Playgroud)
还是我错过了什么?:)