Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0HELP - JQuery stops working after a call backHELP - JQuery stops working after a call back
Previous
 
Next
New Post
1/14/2009 6:24 AM
 

I have a strange issue where I am using jQuery to "slidetoggle" a div when the user clicks on an edit image.

When the page is first loaded, the toggle display works fine. However if the user clicks on a button within the module that results in a AJAX call back (using Supports Partial Rending = yes), the image no longer works.

Here is a snippet of my code

   <!-- This is the image button -->

    <div class="EditImage CCcustomise" tabindex=100></div>
   

    <!-- This is the edit panel div that is displayed via the slidetoggle function -->
    <div class="EditPanel CCEditPanel" style="display:none">
        <br /><br />
        <div style="padding-left:50px">
            <asp:label id="lblDefaultFromCurrency" CssClass="EditWhiteLarge" runat="server" controlname="DDLFromCurrency" ></asp:label><br />
            <asp:DropDownList ID="ddlDefaultFromCurrency"  CssClass="EditDDL"  CausesValidation="false" runat="server"></asp:DropDownList>
            <br /><br />
            <asp:label id="lblDefaultToCurrency" CssClass="EditWhiteLarge" runat="server" controlname="DDLToCurrency" ></asp:label><br />
            <asp:DropDownList ID="ddlDefaultToCurrency"  CssClass="EditDDL"  CausesValidation="false" runat="server"></asp:DropDownList>
            <br /><br />
        </div>
        <div class="EditSeparator">&nbsp;</div>
        <div class="EditButtons" style="padding-left:50px">
            <asp:button id="cmdCCUpdate" resourcekey="cmdUpdate" runat="server" ></asp:button>&nbsp;&nbsp;
            <asp:button id="cmdCCCancel" resourcekey="cmdCancel" class="CCCancel" runat="server" ></asp:button>
        </div>
        <div class="EditSeparator">&nbsp;</div>
    </div>
 

<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript">

        jQuery(document).ready(function() {

        jQuery(".CCcustomise").click(function(event) {
            CCcustomise.click")
                    jQuery(".CCEditPanel").slideToggle("normal");
                });

        });
      
  </script>
 

CSS:

.EditPanel {
    background-color: #737173;
    color: White;
    overflow:hidden;
    font-size: 0.8em;
    width:100%;
    vertical-align:top;
}

.EditImage {
    height: 20px;
    cursor:pointer;
    background-image: url(images/edit-img.gif);
    background-color: Transparent;
    text-align:right ;
    vertical-align: top;
    margin: 4px 4px 4px 260px;
    width: 37px;
}

.EditSeparator
{
    background-image: url(images/SeparatorWhite.GIF);
    background-repeat: repeat-x;
    width:100%;
}

.EditButtons
{
    text-align:left;
    background-color: #737173;
    padding-bottom: 20px;
    margin-left:10px;
}   

.EditDDL
{
    width:160px;
}

 

As you can see I have placed an Alert in the CCcustomise.Click function (where the jQuery SligeToggle is actioned).

On the first load of the page, when clicking on the EditImage, the CCEditPanel is toggled correctly.

 

It is only AFTER an AJAX callback is actioned that this stops working. Clicking on the image simply does nothing.

It is not a problem with the SlideToggle function as the Alert in the click function is not shown.

 

 

Any ideas or suggestions as to what could be going wrong because I am tearing my hair out (what little is still left!) trying to fix this


Blue & White hooped blood runs through my veins!
 
New Post
1/14/2009 10:01 AM
 

When you do a partial postback (AJAX callback), the contents of the UpdatePanel area are replaced.  This means that the click event that you wired-up to the image needs to be re-wired to the new image that the callback created.

Your JavaScript should look something like this:

<script type="text/javascript">

        jQuery(document).ready(function() {
            InitializeBehaviors();

            var scriptManager = Sys.Webforms.PageRequestManager.getInstance();
            if (scriptManager) {
                scriptManager.add_endRequest(InitializeBehaviors);
            }
        });

        function InitializeBehaviors() {
            jQuery(".CCcustomise").click(function(event) {
//                CCcustomise.click")
                        jQuery(".CCEditPanel").slideToggle("normal");
                    });
        }
      
  </script>

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
1/15/2009 4:28 AM
 

Thanks for the reply Brian, what you say makes perfect sense.

 

However I have applied the code and after the AJAX call back I get the following javascript error:

 

Error: 'Sys.Webforms.PageRequestManager' is null or not an object

 

Any ideas why I should get this error?


Blue & White hooped blood runs through my veins!
 
New Post
1/15/2009 10:11 AM
 

I'm not sure why that object/type wouldn't be available to the script in your control.  How are you creating these partial page postbacks?  Are you enabling them in the control definition, or using an UpdatePanel directly, or some other method?

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
1/28/2009 11:17 AM
 

Looks like that error was a typo on my part (though I could've sworn I copied that from a working example).  It needs to be Sys.Webforms (with a capital F) rather than Sys.Webforms.

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0HELP - JQuery stops working after a call backHELP - JQuery stops working after a call back


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out