mcDropdown v1.2 released...

Categories: jQuery

Addressing some more behavior issues being brought up (and adding a few new features,) Giva just released a new version of the mcDropdown plug-in:

  • Added focus() method
  • Fixed autocomplete list from showing dropdown when go back levels in FF3
  • Fixed autocomplete list corruption in when go back levels after using mouse
  • Added tabindex="-1" to the dropdown arrow (so it shouldn't recieve focus on tabbing)
  • Fixed tabbing behavior so hitting [TAB] should go to the next element in the tabindex
  • Autocomplete no longer shows (by default) if the input is empty and recieves focus (use the setting.showACOnEmptyFocus to control this behavior)
  • Added setting.showACOnEmptyFocus (used for controlling whether the autocomplete list shows on focus if list is empty; default = false)
  • Fixed noConflict() bug (where $ wasn't being properly scoped)

Comments

johnny's Gravatar nice script!

i have a dumb question, why is it that <input type="text" name="category" id="category"> does not show up when I use this script in a form? when I select a dropdown selection, it puts it in the text field, but nothing is posted when I submit the form.

thanks
Dan G. Switzer, II's Gravatar @johnny:

Do you have an example of a page causing the problem?
johnny's Gravatar its not a live page, and i dont think i can paste all the html code, but all I did was copy the example from http://www.givainc.com/labs/mcdropdown_jquery_plug... using v1.2

essentially, I load the three js scripts, the mcdropdown css, then I have
<ul id="categorymenu" class="mcdropdown_menu">
with alot of various ul and li rel=....
<tr><td align=left>test dropdown menu</td><td>
<input type="text" name="category" id="category" value="" />
</td></tr>
and finally the jquery stuff:
<script type="text/javascript">
$(document).ready(function (){
$("#category").mcDropdown("#categorymenu");

});
</script>
johnny's Gravatar just incase it does let me show html code, here it is

<table width=750><form id=idForm name=nameForm method=post action=""><script type="text/javascript" src="./lib/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="./lib/jquery.mcdropdown.js"></script>
<script type="text/javascript" src="./lib/jquery.bgiframe.js"></script>

<!---// load the mcDropdown CSS stylesheet //--->
<link type="text/css" href="./css/jquery.mcdropdown.css" rel="stylesheet" media="all" />

<ul id="categorymenu" class="mcdropdown_menu">
<li rel="1">
Arts &amp; Humanities
<ul>
<li rel="2">
Photography
<ul>
<li rel="3">
3D
</li>
<li rel="4">
Digital
</li>
</ul>
</li>
<li rel="5">
History
</li>
<li rel="6">
Literature
</li>
</ul>
</li>
<li rel="7">
Business &amp; Economy
</li>
<li rel="8">
Computers &amp; Internet
</li>
<li rel="9">
Education
</li>
<li rel="11">
Entertainment
<ul>
<li rel="12">
Movies
</li>
<li rel="13">
TV Shows
</li>
<li rel="14">
Music
</li>
<li rel="15">
Humor
</li>
</ul>
</li>
<li rel="10">
Health
</li>

</ul>

<tr><td align=left>Reason for Ticket</td><td>
<input type="text" name="category" id="category" value="" />
</td></tr>

<script type="text/javascript">
$(document).ready(function (){
$("#category").mcDropdown("#categorymenu");
});
</script>

</form></table>
Dan G. Switzer, II's Gravatar @johnny:

It's because your form tag is inside the table tag. You need to move the form tag outside of the table tag (i.e. <form><table></table></form>.) It's invalid syntax. Most browsers will work w/the invalid syntax, but as soon as you manipulate the DOM, it breaks in some major browsers (either FF or IE--can't remember which one off hand.)
johnny's Gravatar nice catch, you were right on the money! thanks!!
Michael's Gravatar Hi,

great plugin. Is there a something like onchange? I need to fire an ajax script when the user selects something.

I tried the "click" and "select" option, but both fire only once when the drop-down menue is initialized.

michael
Dan G. Switzer, II's Gravatar @Michael,

The "select" option gets invoked when a value is selected (this is either when the user clicks a value or after they've typed a value and the blur event has been triggered.) We're using this internally to fire off events, so it should definitely be working correctly.

Neither the "select" nor the "click" event should fire off initially. Are you sure you're not doing:

{
select: someFunction()
}

That's the only way they'd fire off initiallly (because you're actually executing the functions at runtime--not setting it as an handler.) You need to do either:

{
select: someFunction
}

... or ...

{
select: function (){ someFunction(arg1, arg2); }
}

-Dan
Andrew Rimmer's Gravatar Is there an elegant way of having multiple dropdowns based on the same list?

The scenario I am thinking of is a product category page, were the admin user can select multiple categories. The list of categories is always the same, but each time the user selects the box a new drop down is created.

I attempted to do something similar, binding to 2 different input text elements, but updating one updated all of the dropdowns.
Dan G. Switzer, II's Gravatar @Andrew:

At the moment, this isn't a need we have. However, you can probably get it working with a few modifications to the $(document).bind("click", ...) behavior that starts on line 93. Right now what is happening is the onclick event is being fired for each mcDropdown. What you'd need to do is cancel that event for any dropdown that's not currently open.

If you come up with a working patch, I'll definitely be willing to add it to the source code.
Andrew Rimmer's Gravatar @Dan

After a bit of reflection I decided it probably wouldn't be the most elegant solution anyway. Instead of having a list of mdDropDowns, I now have a list of categories with one mcDropdown used to add new product categories. When a categories is selected, a category gets added to the database, and the text for the category is added to the list.

Thanks for a great control. I have seen a lot of ways to manage hierarchies and categorization and they are usually really clumsy. mcDropdown makes things a lot easier.
Dan G. Switzer, II's Gravatar @Andrew:

Glad the plug-in is working well for you. It's funny, because I've seen some people give negative comments on how this was a poor UI choose. While I don't feel it's perfect, I think it solves a complex UI problem very well.
dew's Gravatar hi. can u help me? i need to change the the psuedo-select box into picture.
jquery.mcdropdown.css - what to change there?
thanx a lot
Dan G. Switzer, II's Gravatar @dew:

My best advice is some generic advise for figuring out how to alter CSS to accomplish the task you want--and that's to user Firefox w/Firebug. The Firebug addon will allow you to easily change the CSS in a live editing mode--which makes it very easy to figure out what tweaks you need to make. I find the tool invaluable when tweaking my CSS to get the effect I need.

However, for the mcDropdown specifically, you'll want to do a couple of things:

1) Use a <div> instead of an <input> for the control. The <div> element is a read-only version.

2) Change the div.mcdropdown div rule to have a display: none (this should prevent the text from showing up altogether.)

3) Change all the div.mcdropdown a (and div.mcdropdown a:*) rules to match the image you want to use. This is the default dropdown image handler.

You may need to make other tweaks, but all of the tweaks should be within the div.mcdropdown selector.
Sean O's Gravatar I second Andrew's request for multiple mcdropdowns pointing at one master list. I can see a few instances where this would be useful. Perhaps as a multiple: true/false option?
jeff's Gravatar Dan, nice plugin, I'm sure I'll use it often. I'm looking for an example of how to setup or receive a change event to allow me to use the user selection to hide/show various page elements. I've currently got "$jquery->script('var dd = $(".mcdropdown_menu li").change( function() { alert("here")})');" but it's not being triggered. Thoughts?
Dan G. Switzer, II's Gravatar @Jeff:

The event is "select", not "change".
Dan G. Switzer, II's Gravatar Also, it's:

$(".mcdropdown_menu").mcDropdown({
select: function (value, display){
alert("here");
}
});

Please refer to the docs for more options.
mario's Gravatar hello dan!
i still have the same problem. i have played with menu 4 a while but as newbie i just give up 4 a sake of 1 good question... .-)
i would like to show/hide some html code in div container..can u please drop some line of code as example? i would really like to use this solution on something im working on for a while...
thx! :-)
Junaid Ali Qureshi's Gravatar Hey, using IE 6, JQuery 1.2.6 and the latest MCDropDown i ran into an issue. when the third level of the dropdown is called the width element seems to have a NaN value, does not load and gives an exception in jquery att: extend, i added an 'try catch --do nothing' to the code it seems to force the error override but minor other issues are evident.
Junaid Ali Qureshi's Gravatar Ya and by the way, Nice Work!
Dan G. Switzer, II's Gravatar @Junaid:

Are you sure you're running the latest version (v1.2.07?) I know there's no general problem, because most of the menus we have are at least three levels deep.

Is there a code example somewhere I can look?

I'd most likely suspect it's something in your HTML. Even the example on the download page has an example three levels deep that works fine (Arts & Humanities > Photography.)
Prasad's Gravatar H i have a strange problem if i resize my window The drop down is not adjusting with the <input type="text" name="category" id="category" value=""/> i saw in the css the style as the position is also absoulte how can solve this


Please help[
Dan G. Switzer, II's Gravatar @Prasad:

I don't really understand what your problem is, but do make sure your running the latest version (v1.2.07.) There have been several fixes to address positioning issues.

Also, I would recommend using a fixed width for the input element--do not use a percentage width.
Prasad's Gravatar HI we have downloaded the latest version but still the problem was not solved on window-resizing can you please look in to that its very urgent for us..

Problem::
if We open the drop down and resize the window the position of the drop down is not matching with the input field

This is the url::
http://74.86.247.218/dvdplay/index.php?m=movie&...
Dan G. Switzer, II's Gravatar @Prasad:

Since that's a pretty corner use case, I'd recommend just doing something like:

$(window).bind("resize", function (){
$("#category").mcDropdown().closeMenu();
});

A normal select element will close automatically when the browser resizes, so this would be consistent with how the select element works.
Prasad's Gravatar Thank you for ur response dan i am keeping the present code how ever i will try to adjust the left margin of the menu to be adjusted according to the window resize,....

Add Comment



If you subscribe, any new posts to this thread will be sent to your email address.