I have the following issues when using jquery scripts in the page with ajax manager although I used radscriptblock rounding my script as documented:
1- when using radscriptblock inside updated ajax panel it will be executed in the load but if I make any ajax request manually using "ajaxRequest" function it will be executed again although I need it to be executed only one time [on page load]
2- when using radscriptblock out of updated ajax panel, it will be also executed in the load but if I make any ajax request manually using "ajaxRequest" function it will be no longer executed any more [after going to server side]
below is my code:
PAGE:
Collapsible.panel.js
1- when using radscriptblock inside updated ajax panel it will be executed in the load but if I make any ajax request manually using "ajaxRequest" function it will be executed again although I need it to be executed only one time [on page load]
2- when using radscriptblock out of updated ajax panel, it will be also executed in the load but if I make any ajax request manually using "ajaxRequest" function it will be no longer executed any more [after going to server side]
below is my code:
PAGE:
<head> <script src="http://localhost/xsurvey/scripts/custom/collapsible.panel.js" type="text/javascript"></script></head><%--below is body--><asp:ScriptManager runat="server" ID="scrt" /> <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="OnAjaxManager_Request"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="PnlPage"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="PnlPage" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="PnlPage" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <asp:Panel runat="server" ID="PnlPage"> <telerik:RadScriptBlock runat="server" ID="s"> <script type="text/javascript"> $(document).ready(function() { function test() { $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest('sss'); } alert("d"); $("#faq").makeCollapsible({ 'collapse': '1' }, test); }); </script> </telerik:RadScriptBlock> <asp:Label runat="server" ID="LblEd" /> <ul id="faq"> <li> <h3 style="text-align: center"> More Options?</h3> <p> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> </p> </li> <li> <h3 style="text-align: center"> More Options?</h3> <p> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> test test test <br /> </p> </li> </ul> </asp:Panel>using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using Telerik.Web.UI;public partial class Tests_jQuery_CollapsePanel : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void OnAjaxManager_Request(object sender, AjaxRequestEventArgs e) { LblEd.Text = "test test CALL SERVER" + DateTime.Now; }
}Collapsible.panel.js
(function($) { $.fn.makeCollapsible = function(options, onCollapse) { var settings = $.extend({ 'collapse': '1', 'idToCollapse': '' }, options); return this.each(function() { var $this = $(this); $this.find("li > h3").each(function() { $(this).css("cursor", "pointer"); $(this).siblings().wrapAll('<div>'); }); //$("#faq li > *:not(h3)").hide(); $this.find("li > h3").click(function() { var $h3 = $(this); //minus icon var minus = { 'background-image': 'url(http://localhost/xsurvey/Images/minus.gif)' }; //plus icon var plus = { 'background-image': 'url(http://localhost/xsurvey/Images/plus.gif)' }; //all siblings beside <li><h3></h3>(.....)</li> var risposta = $h3.siblings(); var callf = 0; if (risposta.is(':hidden')) { $h3.css(minus); callf = 1; risposta.slideDown("slow"); } else { $h3.css(plus); risposta.slideUp("slow"); } //risposta.slideToggle("slow"); if (callf == 1 && settings.onCollapse != '') { //setTimeout(alert('s'), 2000); if (typeof onCollapse == "function") onCollapse(); } }); }); }})(jQuery);