PDA

View Full Version : avoid control overwrite itself jquery


vkdixit
03-25-2009, 06:21 AM
hi all,
I am trying to create runtime controls but when control comes from anothe page. they are overwriting itself...
my code is :


<script src="include/jquery-1.2.6.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){


//phone no.
$("#add_phone").click(function(){

$.post("ajax1.asp",{action:'phonepost',pid:<%=Request("pid")%>},function(msg){

$("#phone_output").html(msg);
$("#phone_output").load("ajax1.asp?pid=<%=Request("pid")%>&action=viewphone");

});

});


});

</script>


and code from the control comes:


<%
if Request("action") ="phonepost" then
per_id=Request("pid")
end if
if Request("action") ="phonepost" or Request("action")="viewphone" then
%>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="80%"><input type="text<%=per_id%>" size="60" value="Enter Phone" name="textfield" onclick="if(this.value=='Enter Phone')this.value='';" onblur="if(this.value=='')this.value='Enter Phone';" /></td>
<td width="17%" align="left"><select id="Phone_relation" name="Phone_relation<%=per_id%>">
<option value="Work" selected="selected">Work</option>
<option value="Mobile">Mobile</option>
<option value="Fax">Fax</option>
<option value="Home">Home</option>
</select></td>
<td width="3%" align="right"><a href="?action=delete&id=<%=per_id%>&pid=<%=per_id%>"><img src="images/remove.gif" style="cursor:pointer" title="Delete" id="btn_delete" border="0"/></a></td>
</tr>
</table>

<%
response.write "<br>"
end if
%>



plz help....

Eldarrion
03-25-2009, 06:56 AM
If I'm reading this correctly... you're losing the 'click' event assigned to $("#add_phone") when the ajax call completes? Mind you, using code tags within your post is a good idea... for instance, you don't get smilies in the middle of the code itself. :P

Anyways... a solution:


$("#add_phone").live('click', function() {
// Stick what to do upon click here
})


See if that works for you.

vkdixit
04-06-2009, 01:49 PM
If I'm reading this correctly... you're losing the 'click' event assigned to $("#add_phone") when the ajax call completes? Mind you, using code tags within your post is a good idea... for instance, you don't get smilies in the middle of the code itself. :P

Anyways... a solution:


$("#add_phone").live('click', function() {
// Stick what to do upon click here
})


See if that works for you.
thanks