[jQuery] Re: Capture a click outside of a specific object?

2009-01-15 Thread vincent voyer

You can do :

$(document).bind('click', function(e){
var $clicked = $(e.target);
if (!($clicked.is('#element') || 
$clicked.parents().is
('#element'))) {
//click outside, do what you want :)
}
else {
// click inside, to what you want, or 
nothing :)
}
});

that's it !

On 15 jan, 00:14, riotbrrd k...@riotbrrd.com wrote:
 Hmmm, I wasn't able to find anything about that, though I checked only
 quickly. What section fo the docs would that be in?

 On Jan 13, 5:44 pm, Kean shenan...@gmail.com wrote:





  You might want to look at live and die method now posted in jQuery
  documentation.

  On Jan 13, 11:32 am,riotbrrdk...@riotbrrd.com wrote:

   Hi all,

   Is there a simple way to capture a click event in a window/document
   and then determine whether the click was inside an element #foo, or
   outside of that element?

   Thanks!
   -Kim- Hide quoted text -

  - Show quoted text -


[jQuery] Re: easy way to get all input value

2008-06-13 Thread vincent voyer

Hello,

$('#myform').serializeArray() will give you a great Json object to
work with ! (And send it to a $.post request for example)

Dunno if it's what you were searching for but i use it very often to
send data to an ajax request

On Jun 13, 4:56 am, Jack Killpatrick [EMAIL PROTECTED] wrote:
 I asked this via another thread, but no reply yet... so tossing it in here, 
 too. Do you know if *any* selector can be used with .formHash() or just an id 
 for a form? IE, if I have a few divs inside a form can I use a div id to just 
 get the formHash for form fields inside that div?
 Thanks,
 a different Jack
 Dan G. Switzer, II wrote:Jack, The Field plug-in has a formHash() method 
 which does exactly that:http://jquery.com/plugins/project/fieldYou can see an 
 example 
 here:http://www.pengoworks.com/workshop/jquery/field/field.plugin.htmIf you 
 are using Firebug, you can see the dump of the form in your console when you 
 click the $('#frmTest').formHash() button. -Dan-Original Message- 
 From:[EMAIL PROTECTED]:[EMAIL PROTECTED] On Behalf Of jack Sent: Thursday, 
 June 12, 2008 9:52 PM To: jQuery (English) Subject: [jQuery] easy way to get 
 all input value Hi, all Is there an easy way to get all the input values on a 
 form into an object? Thank you very much! Jack


[jQuery] Re: Selecting Row When Checkbox in a TD is Checked?

2008-06-13 Thread vincent voyer

Correct syntax :

$(.Dinner:checked).parent().parent().show();

$(.Dinner :checked) means :checked items chidren of .dinner
elements wich is not what you want

And remove that center/center thing PLEASE ! (use at least td
style=text-align:center or write a css rule)

:)

On 13 juin, 03:53, Vik [EMAIL PROTECTED] wrote:
 I found a way to do it.

  $(#Filter_Dropdown).change(function () {
 var str = ;
 var orig_str = ;
 orig_str = $(#Filter_Dropdown option:selected).text();
 str = '.' + orig_str;

 $(.food_planner tbody tr).show();
 if (str != '.Show All')
 {
 $(.food_planner tbody tr).hide();
 $([EMAIL PROTECTED] + orig_str +
 ]:checked).parent().parent().parent().show();
 }
 });


[jQuery] Re: Hide/Close div when clicked outside of it.

2008-06-05 Thread vincent voyer

Hello, for those wondering, if you want to know whenever you click
outside a div and byt outside i mean everywhere but the div like you
want to display an error message :

html
head
titletest error click outside/title
style type=text/css
p.error {
position:absolute;
top:40%;
left:30%;
width:40%;
/style
/head
body
blaeblalblpdsqdsq/pspanfsqf/span
div id=onefsqfqsf/div

p class=errorspanERROR :/span emClick outside this paragraph
to close it, you can even click on me !/em/p

div clas=fslfqs/div

!-- THIS IS THE PART THAT YOU WANT TO LOOK AT ;) --
script type=text/javascript

$(document).bind('click', function(e) {

var $clicked=$(e.target); // get the element clicked

if($clicked.is('.error') || $clicked.parents().is('.error')) { 
// if
the element clicked is the one we're looking for or if the element has
a parent that we're looking for then we clicked the right place !
console.log('BULLSEYE !'); // here you should do 
anything
} else { // we're outside the error paragraph, no matter where 
but
we're outside !
console.log('you clicked outside the error paragraph,
congrats !'); //here you should close the message :)
}

});

/script

/body
/html

This works in FF, IE7 (expect for the console.log thing ...), didnt
tested it in ie6 etc... But think it works.

If you just want to close it then :

script type=text/javascript
$(document).bind('click', function(e) {

var $clicked=$(e.target); // get the element clicked

if( ! ( $clicked.is('.error') || 
$clicked.parents().is('.error') ) )
{
$('.error').hide();
}

});
/script

Let me know if that work for you

On 2 mai, 20:35, Aleksandr [EMAIL PROTECTED] wrote:
 Everything is working now.
 Thanks to all.
 Last version of code is:

 $(document).ready(function(){
 $(#link).click(function(){
 if ($(#divLoginBox1).is(':hidden'))
 $(#divLoginBox1).show();
 else{
 $(#divLoginBox1).hide();
 }
 return false;
 });

 $('#divLoginBox1').click(function(e) {
 e.stopPropagation();
 });
 $(document).click(function() {
 $('#divLoginBox1').hide();
 });
 });

 On May 2, 7:29 pm, Josh Nathanson [EMAIL PROTECTED] wrote:

  Looks like you are missing a semicolon which will choke IE:

  $(#link).click(function(){
 if ($(#divLoginBox1).is(':hidden'))
 $(#divLoginBox1).show();
 else{
 $(#divLoginBox1).hide();
 }
 return false;
 })   -- ADD SEMICOLON HERE

  -- Josh

  - Original Message -
  From: Aleksandr [EMAIL PROTECTED]
  To: jQuery (English) jquery-en@googlegroups.com
  Sent: Friday, May 02, 2008 11:00 AM
  Subject: [jQuery] Re: Hide/Close div when clicked outside of it.

   I am now have this jQuery code and it is working in FireFox, Safari
   and Opera but not in IE 6, 7:

   $(document).ready(function(){
  $(#link).click(function(){
  if ($(#divLoginBox1).is(':hidden'))
  $(#divLoginBox1).show();
  else{
  $(#divLoginBox1).hide();
  }
  return false;
  })

  $('#divLoginBox1').click(function(e) {
  e.stopPropagation();
  });
  $(document).click(function() {
  $('#divLoginBox1').hide();
  });
   });

   On May 2, 6:00 pm, sawmac [EMAIL PROTECTED] wrote:
   try this

   $('#divLoginBox1').click(function(e) {
e.stopPropagation();});

   $(document).click(function() {
$('#divLoginBox1').hide();

   });

   --dave