views:

534

answers:

1

Hi, I am having a strange issue with jQuery (1.4.2) and Colorbox (1.3.6). I have an hyperlink inside an Obout grid created via a GridTemplate. The issue is with a dynamic href that I am executing with JQuery as follows:

The grid hyperlink passes the Primary Key of a record to this function where I change the href of a link than opens an iframe inside a ColorBox lightbox. This works well on the first record pressed. However, every subsequent click executes the hyperlink with the first parameter passed. Why is the href not refreshing or changing to the new parameter passed? Is there a better way to accomplish this?

        function PopupLink(vReqItrID) {
         var lnkPopup = $("a[id=lnkPopup]");
         lnkPopup.attr("href", "VendorInfo.aspx?ReqItr=" + vReqItrID.toString());
         lnkPopup.trigger("click");

    }

 <script type="text/javascript">
     $(document).ready(function() {
         // Assign the ColorBox - Popup iframe event to element
        $("#lnkPopup").colorbox({ width: "90%", height: "85%", iframe: true, overlayClose: false }); 
     });
</script><a id="lnkPopup" href="#" style="visibility: hidden;"></a>  

    <obout:gridtemplate runat="server" id="tplOpenRequest">                    
        <Template>   
             <a id="lnkReqItr" href="javascript:PopupLink('<%# Container.DataItem("ReqItrID") %>')">Open Request</a>                 
         </Template>            
    </obout:gridtemplate>

Any Help is greatly appreciated. Thanks, Diego.

A: 

Silly me, I guess reading the Colorbox documentation would have helped. I could have just done...

   function PopupLink(vReqItrID) {
        $.fn.colorbox({ href: "VendorInfo.aspx?ReqItr=" + vReqItrID.toString(),
                        width: "90%", height: "85%", iframe: true,  
                        overlayClose: false, open: true });
    }

and forget about the trigger which was the part that was failing. Thanks.

Diego