Results 1 to 5 of 5

Thread: Making Ajax Side Panel refresh parent page when panel is closed.

  1. #1
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Making Ajax Side Panel refresh parent page when panel is closed.

    Script Title: Ajax Side Panel

    Script URL (on DD): http://www.dynamicdrive.com/dynamici...xsidepanel.htm

    Hi, I'm really new to java script so have no idea what I'm doing so sorry if I sound really stupid. I managed to get the script to work, and I have a page that is editable using php, and when you click on the edit button the ajax side panel is activated and contains the editing form.

    After user clicks submit the form does its thing and the panel stays open, I was just wondering how do I get the parent page to reload when the side panel is closed?

    I found some things like this:

    window.top.location.href=theLocation;
    window.parent.location.href=theLocation;
    window.top.location.replace(theLocation);

    only problem is I don't know where to put it..please help

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, the close button isn't on the page inside the iframe, so you don't need any parent or top stuff. Using a text only editor like NotePad, find this inside the ddajaxsidepanel.js file and add the highlighted:

    Code:
    	showhidepanel:function(url, action, type){
    		var $ = jQuery, setting = this.setting
    		var panelstate =  this.$panelref.data('state')
    		var winwidth = $(window).width(), panelwidth = this.$panelref.outerWidth()
    		if (panelwidth < parseInt(setting.openamount_minthreshold))
    			return true
    		if (setting.openamount_maxwidth && setting.openamount_maxwidth > setting.openamount_minthreshold)
    			panelwidth = Math.min(panelwidth, parseInt(setting.openamount_maxwidth))
    		if (action =="show" && panelstate == "open")
    			this.$panelref.animate({left: '+=50'}, function(){
    				ddajaxsidepanel.loadcontent(null)
    			})
    		var finalcss = (action=="show")? {left: winwidth-panelwidth, opacity: 1} : {left: winwidth, opacity: 0}
    		this.$panelref.animate(finalcss, setting.fx.dur, (this.$panelref.data('state')=='open')? 'easeOutBack' : setting.fx.easing, function(){
    			ddajaxsidepanel.loadcontent(url, type)
    		})
    		if(action === 'hide'){widow.location.reload();}
    		return false
    	},
    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Well, the close button isn't on the page inside the iframe, so you don't need any parent or top stuff. Using a text only editor like NotePad, find this inside the ddajaxsidepanel.js file and add the highlighted:


    if(action === 'hide'){widow.location.reload();}
    return false
    },

    [/CODE]

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    Thank you that worked, apart from now if I click anywhere on the page it refreshes, is there anyway to make it only refresh once after the the iframe is hidden?

    Unfortunately site isn't online right now so I can't send you a link.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, actually that shouldn't have worked. I misspelled window as widow. Maybe you fixed that when you edited the file. Try this:

    Code:
    	ddajaxsidepanel.showhidepanel=function(url, action, type){
    		var $ = jQuery, setting = this.setting
    		var panelstate =  this.$panelref.data('state')
    		var winwidth = $(window).width(), panelwidth = this.$panelref.outerWidth()
    		if (panelwidth < parseInt(setting.openamount_minthreshold))
    			return true
    		if (setting.openamount_maxwidth && setting.openamount_maxwidth > setting.openamount_minthreshold)
    			panelwidth = Math.min(panelwidth, parseInt(setting.openamount_maxwidth))
    		if (action =="show" && panelstate == "open")
    			this.$panelref.animate({left: '+=50'}, function(){
    				ddajaxsidepanel.loadcontent(null)
    			})
    		var finalcss = (action=="show")? {left: winwidth-panelwidth, opacity: 1} : {left: winwidth, opacity: 0}
    		this.$panelref.animate(finalcss, setting.fx.dur, (this.$panelref.data('state')=='open')? 'easeOutBack' : setting.fx.easing, function(){
    			ddajaxsidepanel.loadcontent(url, type)
    		})
    		if(action === 'hide' && panelstate === 'open'){window.location.reload();}
    		return false
    	},
    It will still reload on a click to the document, but only if the panel is open, which would close the panel anyway.
    Last edited by jscheuer1; 08-02-2013 at 03:57 AM. Reason: detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Perfect that was just what I was after, thank you very much for your help!

Similar Threads

  1. Ajax Side Panel script
    By Wakel in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 07-07-2013, 10:07 AM
  2. Ajax Side Panel script AND Ultimate Fade-in slideshow (v2.4) not getting along.
    By WebDizzy777 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 12-21-2012, 02:31 AM
  3. Ajax Side Panel script works in everything but IE
    By dennisg in forum Dynamic Drive scripts help
    Replies: 8
    Last Post: 11-03-2012, 05:15 AM
  4. Ajax Side Panel script not working properly on my site with IE 9
    By KSRichard in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-11-2012, 07:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •