This is a migrated thread and some comments may be shown as answers.

[Solved] Ajax & JQuery

3 Answers 207 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Gavin Howlett-Foster
Top achievements
Rank 1
Gavin Howlett-Foster asked on 06 Dec 2008, 12:23 AM
I've just started experimenting with JQuery to see how I might use it on my web sites. Most of my pages use Ajax and have controls on it that perform a partial postback. This causes a problem with JQuery as the event that sets up all the nice attributes and animations isn't run after a partial postback.

What you end up with is all the JQuery stuff working when the page is first loaded but stops working after a partial postback. All I wanted to do as an experiment was add some rounded corners to <div> elements. Looked good on first load but choose something from an ajaxified combobox and everything goes square again.

I also downloaded the telerik example project that animated a combobox by sliding the items as you hovered over them but when I ajaxified it to say populate another dropdown list after selecting an item the sliding stopped.

I've searched around for a way around this but to no avail as yet. Just wondered if anyone here knew how to get round this. It just might be that JQuery is not suitable in thsi scenario yet.

Thanks for your help.

3 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 08 Dec 2008, 10:39 AM
Hello Gavin,

If you wrap your script blocks with RadScriptBlock, RadAjax will executed these scripts automatically.

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ravi Keshwani
Top achievements
Rank 1
answered on 03 Aug 2009, 12:42 PM
Hi Guys,

  I am  using plugins provided by Jquery and not of telerik. I have a grid with usercontrol for edit and insert. I have added Jquery for validating the controls in usercontrol. It was working until I had added Ajax panel in WebPage. The Jquery Validation is not firing.below is my code of jquery in usercontrol

<

 

telerik:RadScriptBlock ID="Rad1" runat="server">

 

<

 

script type="text/javascript">

 

 

 

jQuery.validator.addMethod(

 

"selectNone",

 

 

function(value, element) {

 

 

 

if (element.value == "-1")

 

{

 

return false;

 

}

 

else return true;

 

},

 

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

 

);

$(document).ready

(

 

alert(

"ready");

 

 

 

function() {

 

$(

"input[name$='btnInsert']").click(function()

 

{

 

Validate();

});

$(

"input[name$='btnUpdate']").click(function()

 

{

 

Validate();

});

$(

"input[name$='btnCancel']").click(function()

 

{

 

cancelValidation();

});

 

 

 

}

);

 

 

function cancelValidation()

 

{

 

 

//$("input[name$='btnInsert']").unbind('click',Validate)

 

 

 

return true;

 

 

}

 

function Validate()

 

{

alert(

"Before");

 

 

 

if(document.getElementById("<%= txtWebSite.ClientID %>").value.length<=8)

 

{

document.getElementById(

"<%= txtWebSite.ClientID %>").value="";

 

}

document.getElementById(

"<%= MessageRow.ClientID %>").style.visibility='hidden';

 

 

$(

"#aspnetForm").validate

 

(

{

rules:

{

 

<%= txtCompName.UniqueID %>:

"required",

 

<%= txtWebSite.UniqueID %>:

{

 

url:

true

 

},

<%= txtEmail.UniqueID%>:

{

required:

true,

 

email:

true

 

},

<%= txtContactPersonEmail.UniqueID%>:

{

 

email:

true

 

},

<%= drpCompanyType.UniqueID%>:

{

selectNone:

true

 

}

,

<%= drpCompanyType.UniqueID%>:

{

selectNone:

true

 

}

,

<%= txtPhone.UniqueID%>:

{

required:

true

 

}

 

 

},

messages:

{

<%= txtCompName.UniqueID%>:

{

required:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

},

<%= txtWebSite.UniqueID%>:

{

url:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

},

<%= txtEmail.UniqueID%>:

{

required:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />",

 

email:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

},

<%=txtContactPersonEmail.UniqueID%>:

{

email:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

},

 

<%= drpCompanyType.UniqueID%>:

{

selectNone:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

}

,

<%= txtPhone.UniqueID%>:

{

required:

"&nbsp;&nbsp;<img src='../../Images/ModalDialogAlert.gif' />"

 

}

 

 

},

invalidHandler:

function(form, validator)

 

{

 

document.getElementById(

'<%= MessageRow.ClientID %>").style.visibility='visible';

 

 

}

 

}

);

 

}

 

 

 

 

</script>

 

 

</telerik:RadScriptBlock>

 

 
0
Dimo
Telerik team
answered on 05 Aug 2009, 08:44 AM
Hi Ravi Keshwani,

You should place the RadScriptBlock in an updated control, which is updated together with RadGrid.

If the above does not help, please send a complete runnable web page.


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Gavin Howlett-Foster
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Ravi Keshwani
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or