📜 ⬆️ ⬇️

Replacing standard select using Mootools

Sometimes you need to replace the standard HTML element with your own.
This is usually necessary if the designer’s imagination has played out and he has drawn a “customized” select and insists that it be implemented as he wanted. Well, we must do it.

A little background.

Once I needed to customize select. I use mootools, so I immediately went looking for a plug-in to replace select'a - what if someone had already written? Indeed found a few. Began to understand. All the plugins I looked at turned out to be complete nonsense - they did not behave like a standard select. I threw them in the trash and decided to write my own plugin that would completely repeat the behavior of the standard select'a.

Let's now see how standard select behaves:

Closer to the point


I will not give here the code of what happened - it does not need anything. Better download and see for yourself, or check out the demo . But I will talk about what happened.

What happened


So, get your "custom" selectbox. And that's what he can do:

What are the problems at the moment?


  1. You can not change the type of scroll bar that appears in the select box with a large number of options
  2. So far, the selectbox can only fall down, and should fall up, if there is not enough space below
  3. There is no multiple mode
  4. Timeout when spinning, so that the option when the mouse is moved while scrolling is not immediately highlighted (for a native select, this is exactly the case)
  5. Does not change the appearance when you click
  6. If there is a scroll, it should automatically scroll when selecting items.
  7. If you click on the menu item, then remove the mouse, then when you press Enter, this element should be selected

I will try to fix all these problems in the following releases.
')
It was tested only in IE 7, Firefox 3.0.1, Google Chrome (look at somebody, in Opera and IE6 how?)

If something is missed - report. And, of course, report found bugs, I will correct.

Download CustomSelect
View demo

Source: https://habr.com/ru/post/40468/


All Articles