List Info

Thread: close a div when click out of the div




close a div when click out of the div
user name
2007-04-17 08:25:11
Hi. I have this question: I have a page with more ugual "GIF" (say ?/Help gif). When I click on one of this giv a "DIV" is showed (one for each gif). And when a div is showed the last div "showed" there must "hide". Ok, no problem. I have do it. My problem is that the div that is showed in this moment must to "hide" when I clink into the document (is not important where). Onto firefox I have resolved in this way with the use of Event:

mostraDivHelp(div) {
    //If is there a div "open" I hide it.
   ; if (SHEEBOO_scambio[';divHelp9;] !== undefined && SHEEBOO_scambio['divHelp';] != null) {
        $(SHEEBOO_scambio[9;divHelp']).hide();
   ;     Event.stopObserving(document,9;click';,function(e) {if (e.target.attributes !== undefined) return false;nascondiDivHelp(div);});
    }

    SHEEBOO_scambio['divHelp';] = div;
 ;   $(div).setStyle({display:'block'});
    SHEEBOO_scambio['primoClick'] = 0;
    Event.observe(document,'click',function(e) {if (e.target.attributes.alt !== undefined) return false;nascondiDivHelp(div);});
}

function nascondiDivHelp(div) {
   ; Event.stopObserving(document,9;click';,function(e) {if (e.target.attributes !== undefined) return false;SHEEBOO_nascondiDivHelp(div);});
    SHEEBOO_scambio['divHelp';] = null;
    $(div).hide();
}

It works in FF, but not in IE. In IE the event "e" is always "empty".

Where is my error ? Is there a more beautifull solution ?

Tnx.

Michel.
--
Michel 'ZioBudda' Morelli        ;           ;    michelziobudda.net">michelziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net   ;           ;           ICQ: 58351764
http://www.ziobuddalabs.it ;           ;          Skype: zio_budda
http://www.ajaxblog.it      ;           ;          MSN: michelziobuddalabs.it">michelziobuddalabs.it
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: close a div when click out of the div
user name
2007-04-17 08:35:48
You should use the Event.element(e) instead if e.target to
make it
work in all browsers.

On 4/17/07, zio budda <ziobuddagmail.com> wrote:
> Hi. I have this question: I have a page with more ugual
"GIF" (say ?/Help
> gif). When I click on one of this giv a "DIV"
is showed (one for each gif).
> And when a div is showed the last div
"showed" there must "hide". Ok, no
> problem. I have do it. My problem is that the div that
is showed in this
> moment must to "hide" when I clink into the
document (is not important
> where). Onto firefox I have resolved in this way with
the use of Event:
>
> mostraDivHelp(div) {
>     //If is there a div "open" I hide it.
>     if (SHEEBOO_scambio['divHelp'] !== undefined
&&
> SHEEBOO_scambio['divHelp'] != null) {
>         $(SHEEBOO_scambio['divHelp']).hide();
>        
Event.stopObserving(document,'click',function(e) {if
> (e.target.attributes !== undefined) return
false;nascondiDivHelp(div);});
>     }
>
>     SHEEBOO_scambio['divHelp'] = div;
>     $(div).setStyle({display:'block'});
>     SHEEBOO_scambio['primoClick'] = 0;
>     Event.observe(document,'click',function(e) {if
(e.target.attributes.alt
> !== undefined) return false;nascondiDivHelp(div);});
> }
>
> function nascondiDivHelp(div) {
>     Event.stopObserving(document,'click',function(e)
{if
> (e.target.attributes !== undefined) return
> false;SHEEBOO_nascondiDivHelp(div);});
>     SHEEBOO_scambio['divHelp'] = null;
>     $(div).hide();
> }
>
> It works in FF, but not in IE. In IE the event
"e" is always "empty".
>
> Where is my error ? Is there a more beautifull solution
?
>
> Tnx.
>
> Michel.
> --
> Michel 'ZioBudda' Morelli                      
michelziobudda.net
> Consulenza sistemistica in ambito OpenSource.
> Sviluppo applicazioni web dinamiche (LAMP+Ajax)
> Telefono: +39-3939890025 --  Fax: +39-0291390660
>
>  http://www.ziobudda.net  
                      ICQ: 58351764
> http://www.ziobuddalabs.it
                      Skype: zio_budda
> http://www.ajaxblog.it    
                      MSN: michelziobuddalabs.it
>  >
>


-- 
burnfield.com/martin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: close a div when click out of the div
user name
2007-04-17 09:46:15
2007/4/17, Martin Ström < martinstromlistsgmail.com">martinstromlistsgmail.com>:

You should use the Event.element(e) instead if e.target to make it
work in all browsers.


Tnx. It works.

M.
--
Michel 'ZioBudda' Morelli&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  michelziobudda.net">michelziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: +39-3939890025 -- &nbsp;Fax: +39-0291390660

http://www.ziobudda.net   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ICQ: 58351764
http://www.ziobuddalabs.it ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  Skype: zio_budda
http://www.ajaxblog.it  &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  MSN: michelziobuddalabs.it">michelziobuddalabs.it
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs&quot; group.
To post to this group, send email to rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )