I have 2 javascript files included in a popup (simple div) generated using ajax.
<script type="text/javascript" src="<?php echo JS ?>pm.js"></script>
<script type="text/javascript" src="<?php echo JS ?>chat.js"></script>
When you close the popup and re-open it, the jQuery bound functions in the two files execute twice.
for example
//connection
$(document).bind('connect', function() {
var conn = new Strophe.Connection('my-http-binding-url');
conn.connect(inbox.data.jid, inbox.data.pass, function(status){
inbox.connection = conn;
alert(status)
});
});
First time I open the popup, it displays the alert message : 5, which means it connected successfully.
But when I close the popup, and re-open it, it shows me the message twice... I assume the code is executed twice because it's not unloaded.
var connect=function(){}or something like that But here I have a bound function, how can I achieve that?