On 6/10/06, Jon <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I'm having trouble using MochiKit (I'm more of a designer than a
> developer).
> Anyway, I hope this is the right place to post, and I hope someone can
> help me.
>
> Basicly what I want is this:
> When someone mouseover a object with the id "siste", there will be
> generated a div, containing a h2 element and an image. And when they
> mouseout of it, it will disappear.
>
> What I've managed so far:
>
> sisteinfo = ["Header", "image.png"];
>
> boks = DIV({'id': 'siste-utgivelse'},
>         H2(null, sisteinfo[0]),
>         IMG({'src': sisteinfo[1]}));
>
> div = toHTML(boks);
>
> (Don't pay attention to the names, they are mostly in Norwegian, and
> you really don't have to understand them.)
>
> Can anyone help me with the script/give me any pointers?
>
> Thanks a lot!
> Jon

You'll need to create functions for inserting and removing the div and
them connect them to $('siste') on mouseover and mouseout.

sisteStuff = function(){

  insert = function(){
   //alter this depending on where you want to insert the node
   appendChildNodes('siste', 'siste-utgivelse');//a mochikit function
  }
  remove = function() {
    siste = $('siste');
   siste.parentNode.removeChild(siste);//removeElement isn't mainline until 1.4
  }

  connect('siste', "onmouseover", insert);
  connect('siste', "onmouseout", remove);
}

Then the whole think will need to be wrapped in an window.onload
handler so the elements are there to be acted on:
connect (window, "onload", sisteStuff);

Another possibility is to load the element with the page but make it
invisible with css (display:none;) and then instead of inserting and
removing it, you toggle visibility with, say showElement(); But see :
http://mochikit.com/doc/html/MochiKit/Style.html#element-visibility

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to