Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 21st Mar 2013, 11:32 AM   #1
Bhadra
 
Join Date: 2012
Posts: 47
Thanks: 18
Thanked 0 Times in 0 Posts
Default
jquery problem
Share on: 
fb share twitter share gplus share more share

Hey warriors,
I have a login system to log users in. For this, I have built the login in a box with display:none in css. After clicking the log in button, the body's opacity is changed from 1 to 0.5 by jquery css() method. The login box appears by using the same css() method. But the problem is that the mouse still responses to the links in the body. So, I want that the links in my website cannot be clicked till the box is closed. Please tell me how to do it?
Thanks in advance.

devaldcool is offline  
Unread 21st Mar 2013, 03:50 PM   #2
Web Developer
War Room Member
 
Andrew H's Avatar
 
Join Date: 2012
Location: Vancouver, BC
Posts: 593
Thanks: 149
Thanked 162 Times in 133 Posts
Default
Re: jquery problem
Share on: 
fb share twitter share gplus share more share

Dont change the opacity of the body, creat a new div inside the body to cover the content.

Code:
//css
#loader {
   width:100%;
   position:absolute;
   display:none;
   background:#333;
   opacity:0.5;
}
//jQuery
$('#modalbox_button').click(function() {
    //fire your login modal here
    var bodyheight = $('body').height();
    $('#loader').css('height', bodyheight);
    $('#loader').css('display', 'block');
});
//HTML
<body>
<div id="loader"></div>
// rest of content
</body>
Something like that.

"You shouldn't come here and set yourself up as the resident wizard of oz."
Andrew H is offline  
The Following User Says Thank You to Andrew H For This Useful Post:
Unread 21st Mar 2013, 04:31 PM   #3
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: jquery problem
Share on: 
fb share twitter share gplus share more share

If all you want to do is make the links in the main content area temporarily un-clickable, then you can simply do this...

Code:
$('.bodyLinks').attr('onClick', 'return false');
And if/when you need to reset those links to work again...

Code:
$('.bodyLinks').attr('onClick', 'return true');
^ The above examples assume all of the links in the main content area are in a class named "bodyLinks" (and that no links in the login popup are in that class).


Brandon Tanner is offline  
The Following User Says Thank You to Brandon Tanner For This Useful Post:
Unread 22nd Mar 2013, 12:15 AM   #4
VIP Warrior
War Room Member
 
SteveJohnson's Avatar
 
Join Date: 2007
Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
Default
Re: jquery problem
Share on: 
fb share twitter share gplus share more share

If you want to make the rest of your page elements unclickable, you'll need to take Andrew's suggestion a little bit further. You'll want to make sure your overlay truly overlays the rest of the page content using z-index (notice 'position: relative' on the dialog box - browsers ignore z-index unless the container has a position other than 'static').

Also, if you don't want to clutter up your page HTML, you can use jQuery to add the overlay container...
Code:
//css
#loader {
    width:100%;
    position:absolute;
    display:none;
    background:#333;
    opacity:0.5;
    z-index: 10001;
}
#dialog-box {
   position: relative;
   z-index: 10002;
}

//jQuery
$('body').append('<div id="loader"></div>');
$('#modalbox_button').click(function() {
     //fire your login modal here
     var bodyheight = $('body').height();
     $('#loader').css('height', bodyheight);
     $('#loader').css('display', 'block');
});
SteveJohnson is offline  
The Following User Says Thank You to SteveJohnson For This Useful Post:
Closed Thread


Bookmarks

Tags
jquery, problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 06:39 AM.