Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $('div._Foo').bind("mouseover", function(e) {
- // Do something exciting
- });
- });
- $(document).ready(function() {
- // bind your jQuery events here initially
- });
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_endRequest(function() {
- // re-bind your jQuery events here
- });
- <script type="text/javascript">
- function BindEvents() {
- $(document).ready(function() {
- $(".tr-base").mouseover(function() {
- $(this).toggleClass("trHover");
- }).mouseout(function() {
- $(this).removeClass("trHover");
- });
- }
- </script>
- <asp:UpdatePanel...
- <ContentTemplate
- <script type="text/javascript">
- Sys.Application.add_load(BindEvents);
- </script>
- *// Staff*
- </ContentTemplate>
- </asp:UpdatePanel>
- <script type="text/javascript">
- function BindControlEvents() {
- //jQuery is wrapped in BindEvents function so it can be re-bound after each callback.
- //Your code would replace the following line:
- $('#<%= TextProtocolDrugInstructions.ClientID %>').limit('100', '#charsLeft_Instructions');
- }
- //Initial bind
- $(document).ready(function () {
- BindControlEvents();
- });
- //Re-bind for callbacks
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_endRequest(function() {
- BindControlEvents();
- });
- </script>
- $(function() {
- $('div._Foo').live("mouseover", function(e) {
- // Do something exciting
- });
- });
- <asp:UpdatePanel runat="server" ID="myUpdatePanel">
- <ContentTemplate>
- <script type="text/javascript" language="javascript">
- function pageLoad() {
- $('div._Foo').bind("mouseover", function(e) {
- // Do something exciting
- });
- }
- </script>
- </ContentTemplate>
- </asp:UpdatePanel>
- function pageLoad() {
- $(document).ready(function(){
- $(document).ready(function() {
- // Do something exciting
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_endRequest(function() {
- // re-bind your jQuery events here
- });
- });
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_endRequest(function() {...
- <script type="text/javascript" language="javascript">
- function pageLoad() {
- // Initialization code here, meant to run once.
- }
- </script>
- pageLoad = function () {
- $('#div').unbind();
- //jquery here
- }
- <script type="text/javascript">
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_endRequest(EndRequestHandler);
- function EndRequestHandler(sender, args) {
- if (args.get_error() == undefined) {
- UPDATEPANELFUNCTION();
- }
- }
- function UPDATEPANELFUNCTION() {
- jQuery(document).ready(function ($) {
- /* Insert all your jQuery events and function calls */
- });
- }
- UPDATEPANELFUNCTION();
- </script>
- Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest)
- function onEndRequest(sender, args) {
- // your jquery code here
- });
- private void ShowForm(bool pShowForm) {
- //other code here...
- if (pShowForm) {
- FocusOnControl(GetFocusOnFormScript(yourControl.ClientID), yourControl.ClientID);
- }
- }
- private void FocusOnControl(string pScript, string pControlId) {
- ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "focusControl_" + pControlId, pScript, true);
- }
- /// <summary>
- /// Scrolls to the form that is made visible
- /// </summary>
- /// <param name="pControlId">The ClientID of the control to focus on after the form is made visible</param>
- /// <returns></returns>
- private string GetFocusOnFormScript(string pControlId) {
- string script = @"
- function FocusOnForm() {
- var scrollToForm = $('#" + pControlId + @"').offset().top;
- $('html, body').animate({
- scrollTop: scrollToForm},
- 'slow'
- );
- /* This removes the event from the PageRequestManager immediately after the desired functionality is completed so that multiple events are not added */
- prm.remove_endRequest(ScrollFocusToFormCaller);
- }
- prm.add_endRequest(ScrollFocusToFormCaller);
- function ScrollFocusToFormCaller(sender, args) {
- if (args.get_error() == undefined) {
- FocusOnForm();
- }
- }";
- return script;
- }
- Sys.Application.add_load(LoadHandler); //This load handler solved update panel did not bind date picker after partial postback
- function LoadHandler() {
- $(document).ready(function () {
- //rebind any events here for controls under update panel
- });
- }
Add Comment
Please, Sign In to add comment