CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Showing a hidden content page (http://www.codingforums.com/showthread.php?t=281359)

danielzd 11-07-2012 06:39 AM

Showing a hidden content page
 
I have the following code that hides a content page on click of the menu to show a google maps in the background. I would like to modify it so that on click, the content page is shown along with the google maps background.


Code:

                                        $bf_menu_items.bind('click', function(e) {
                                                var $item        = $(this);
                                               
                                                hidePageContent();
                                               
                                                var item        = $(this).data('content');
                                                if(item === 'visit') {
                                                        BGMap.showMap();
                                                } else{
                                                        $.when( BGImageController.fadeBG(true) ).done(function(){
                                                                BGMap.hideMap();
                                                        });
                                                        $('#' + $item.data('content')).show();
                                                }       
                                                return false;
                                        });

Thanks in advance!

DanInMa 11-07-2012 03:10 PM

without knowing anything about the other functions on your page or the html, I'll guess that you just need to remove "hidePageContent();" so it doesnt hide the contentpage?

Code:

$bf_menu_items.bind('click', function(e) {
e.preventDefault();
var $itemContent = $(this).data('content');
if($itemContent === 'visit') {
        BGMap.showMap();
 } else {
        $.when( BGImageController.fadeBG(true) ).done(function(){
        BGMap.hideMap();
          });
        $itemContent.show();
 }       
});

I refined your code as well as removed hidecontentpage

- you are using jQuery alreayd so i remove the return false in favor of e.preventDefault()
- you were never really using $item for anything so I did things a little differently.


All times are GMT +1. The time now is 08:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.