tags:

views:

52

answers:

1

Hi, How can i load a part of an external page with jquery overlay?

I have an aspx call TipoFactor.aspx wich has a div inside a contentplaceholder like this:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <br />
        <div id="DivGeneral" runat="server" class="tablaPaddingFiveCeleste">

as you can see the "DivGeneral" is the one i want to load into the overlay, wich is defined like this:

<a href="TipoFactorSeleccion.aspx" rel="#overlay">
                <button type="button">
                    Pagina Externa</button>
            </a>
            <!-- overlayed element -->
            <div class="apple_overlay" id="overlay">
                <!-- the external content is loaded inside this tag -->
                <div class="contentWrap">
                </div>
            </div>
            <script type="text/javascript">
                $(function() {
                    // if the function argument is given to overlay, 
                    // it is assumed to be the onBeforeLoad event listener 
                    $("a[rel]").overlay({

                        expose: 'darkred',
                        effect: 'apple',

                        onBeforeLoad: function() {

                            // grab wrapper element inside content 
                            var wrap = this.getContent().find(".contentWrap");

                            // load the page specified in the trigger 
                            wrap.load(this.getTrigger().attr("href"));
                        }

                    });
                });
            </script>

As it is now its loading the entire page into the overlay and that's not good for me cause it inherites from the same masterpage as the other. I need to keep that masterpage because it has some important aplication functionality.

What can I do ?
Thank you very much.

+2  A: 

Assuming I understand you correctly, when you use the jQuery "load()" API you can sneak in a jQuery selector expression in your URL string:

$('#loadDestination').load('http://some.where/content #onlyThisPart', function() { ... });

that tells jQuery to look for '#onlyThisPart' in the response body, and that's all it adds to your main document.

Thus you'd change your code something like this:

// ...
wrap.load(this.getTrigger().attr("href") + ' #divGeneral');

or whatever the "id" value is that marks where your content starts.

Pointy
thank you pointy, it didn't work but i think its because i don't know much about jquery, just starting to use it. I'm going to include that other page inside the same but as a hidden div. Thank you very much.
rolando