trying to use facebook style tokeninput script which I'll use in the same way as FB uses(using jquery-ui to get the modal window) to send messages to friends in a social networking system.
Clicking on the 'open the dialog' button ('opener' id makes the modal window appear)
javascript snippet:
<script type="text/javascript">
$(document).ready(function() {
$("input[type=button]").click(function () {
alert("Would submit: " + $(this).siblings("input[type=text]").val());
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".show_dialog script").remove();
$dialog = $('.show_dialog');
$dialog.dialog({
width:500,
height:300,
autoOpen: false,
title: 'Basic Dialog'
});
$('#opener').click(function() {
$dialog.dialog('open');
$(this).siblings("input[type=text]").val('this is a value ')// ADDED BY ME
//$("#demo-input-facebook-theme", $dialog).val('');
$(".border_text", $dialog).css("border","1px solid red");
// prevent the default action, e.g., following a link
return false;
});
});
</script>
html snippet is :
<button id="opener">Open the dialog</button>
<div class="show_dialog" style="display:block ;">
<label class="send_meg_recipient_txt">To:</label>
<h2 id="theme">Facebook Theme</h2>
<div>
<input type="text" id="demo-input-facebook-theme" name="blah2" " /><br></br>
<input type="button" value="Submit" />
<script type="text/javascript">
var script = jQuery('<script/>').attr('src', 'js/jquery.tokeninput.js').appendTo('head');
$(document).ready(function() {
var script = jQuery('<script/>').attr('src', 'js/jquery.tokeninput.js').appendTo('head');
var q_string=$("#demo-input-facebook-theme").val();
$("#demo-input-facebook-theme",$dialog).tokenInput("token_find/my3.php?q=q_string", {
preventDuplicates: true,
theme:"facebook"
});
/*
*/
});
</script>
</div>
</div><!--end of class show_dialog-->
I can get the tokenizing from the script.
But after tokenizing for once if i click on the 'opener' id, the modal window appears with its previous tokens retained in place, which I obviously don't want.
How to get rid of it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…