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
Do you have an example of a page causing the problem?
Dan G. Switzer, II
-
Jun 26, 2008
@
4:06 PM
Permalink
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
-
Jun 26, 2008
@
4:40 PM
Permalink
<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 & 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 & Economy
</li>
<li rel="8">
Computers & 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>
johnny
-
Jun 26, 2008
@
4:44 PM
Permalink
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.)
Dan G. Switzer, II
-
Jun 26, 2008
@
5:41 PM
Permalink
johnny
-
Jun 26, 2008
@
6:31 PM
Permalink
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
Michael
-
Jul 4, 2008
@
8:32 AM
Permalink
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
Dan G. Switzer, II
-
Jul 4, 2008
@
9:13 AM
Permalink
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.
Andrew Rimmer
-
Jul 6, 2008
@
6:02 AM
Permalink
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.
Dan G. Switzer, II
-
Jul 7, 2008
@
1:07 PM
Permalink
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.
Andrew Rimmer
-
Jul 11, 2008
@
7:20 AM
Permalink
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.
Dan G. Switzer, II
-
Jul 11, 2008
@
7:50 AM
Permalink
jquery.mcdropdown.css - what to change there?
thanx a lot
dew
-
Jul 22, 2008
@
3:17 AM
Permalink
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.
Dan G. Switzer, II
-
Jul 22, 2008
@
10:49 AM
Permalink
jeff
-
Aug 25, 2008
@
9:10 PM
Permalink
The event is "select", not "change".
Dan G. Switzer, II
-
Aug 26, 2008
@
7:44 AM
Permalink
$(".mcdropdown_menu").mcDropdown({
select: function (value, display){
alert("here");
}
});
Please refer to the docs for more options.
Dan G. Switzer, II
-
Aug 26, 2008
@
7:45 AM
Permalink
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! :-)
mario
-
Aug 27, 2008
@
1:58 PM
Permalink
Junaid Ali Qureshi
-
Sep 12, 2008
@
3:57 AM
Permalink
Junaid Ali Qureshi
-
Sep 12, 2008
@
3:57 AM
Permalink
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.)
Dan G. Switzer, II
-
Sep 12, 2008
@
8:09 AM
Permalink
Please help[
Prasad
-
Sep 22, 2008
@
4:14 AM
Permalink
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.
Dan G. Switzer, II
-
Sep 22, 2008
@
11:29 AM
Permalink
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&...
Prasad
-
Sep 23, 2008
@
6:11 AM
Permalink
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.
Dan G. Switzer, II
-
Sep 23, 2008
@
8:10 AM
Permalink
Prasad
-
Sep 23, 2008
@
9:58 AM
Permalink
But i have one problem in using it,
Can I set width of generated dropdown, i want to display only one column ?
rohit
-
Nov 11, 2008
@
3:38 AM
Permalink
Forcing to one column is basically against the original purpose of the plug-in--which core feature is to ensure that all the items show on the screen. However, you can play with the minRows, maxRows and targetColumnSize options to probably achieve what you want. Just set the minRows/maxRows to a high value and the targetColumnSize to 1.
Dan G. Switzer, II
-
Nov 11, 2008
@
8:12 AM
Permalink
When I click the parent node all is fine, the value is returned correctly. When I click a child node only the child node value is returned. I need the chain parent_value:child_value for processing.
In explorer works nice.
I have the following code :
<html>
<head>
<script type="text/javascript" src="Scripts/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.mcdropdown.js"></script>
<script type="text/javascript" src="Scripts/jquery.mcdropdown.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.bgiframe.js"></script>
<link type="text/css" href="Scripts/jquery.mcdropdown.min.css" rel="stylesheet" media="all" />
<script>
var strCategory;
function fncCambioCliente()
{
document.getElementById("contenido_portafolio").innerHTML="<div id='ajax_loader'><img src='/images/ajax-loader.gif'></div>";
setTimeout("despachaBusqueda()",1500);
}
function despachaBusqueda()
{
ruta=document.getElementById("category").value;
alert(ruta);
compuesto=ruta.indexOf(":");
if (compuesto > 0)
{
arrRuta=ruta.split(":");
txtCliente=arrRuta[0];
txtMarca=arrRuta[1];
}
else
{
txtCliente=ruta;
txtMarca="";
}
url_carga="portafolio_busqueda.aspx";
url_carga+="?prmCliente=" + txtCliente;
url_carga+="&prmMarca=" + txtMarca;
alert(url_carga);
}
</script>
</head>
<body>
<form name="f1" id="f1">
<div id="busca_portafolio">
<input name="category" type="text" id="category" value="Cliente" />
<ul id="categoryMenu" class="mcdropdown_menu">
<li rel="cliente 4">cliente 4
<ul>
<li rel="marca h">marca h</li>
</ul>
</li>
<li rel="cliente 6">cliente 6
<ul>
<li rel="marca j">marca j</li>
</ul>
</li>
<li rel="cliente 8">cliente 8
<ul>
<li rel="marca l">marca l</li>
</ul>
</li>
<li rel="cliente 9">cliente 9
<ul>
<li rel="marca m">marca m</li>
<li rel="marca n">marca n</li>
</ul>
</li>
<li rel="cliente 10">cliente 10
<ul>
<li rel="marca">marca</li>
</ul>
</li>
<li rel="cliente 11">cliente 11
<ul>
<li rel="marca x">marca x</li>
</ul>
</li>
</ul>
</div>
</form>
<div id="contenido_portafolio"></div>
<script type="text/javascript">
<!--//
// on DOM ready
$(document).ready(function (){
$("#current_rev").html("v"+$.mcDropdown.version);
$("#category").mcDropdown("#categoryMenu",{minRows: 25,maxRows: 25,allowParentSelect: true,delim: ":",valueAttr: "rel",select: fncCambioCliente});
});
//-->
</script>
</body>
</html>
thanks for your time.
Ernesto
If you need the chain, then I'd recommend just making the value of your rel="" attribute the chain. So instead of just "marca h" you'd return "cliente 4:marca h"
-Dan
Dan G. Switzer, II
-
Nov 29, 2008
@
11:26 AM
Permalink
$("#backend_nav").mcDropdown("#categorymenu" , { select : function() { alert($("#backend_nav").val())} });
Trying out your control. I had the same issue as Andrew Rimmer - I want to dynamically add dropdowns to the page - each using the same source UL. I've got it working by setting an attribute on the UL each time the anchor is clicked so I know which one was clicked. I'd be curious to hear feedback. Basically I added 3 lines:
in $.mcDropDownMenu I added this.id = el.id;
in open() I added $($list[0]).attr("OpenedMenuID", thismenu.id);
in the click event I modified: var $ul = $target.parents().filter(function (){ return (this === $list[0] && $($list[0]).attr("OpenedMenuID") == thismenu.id) || (!!$keylist && $keylist[0] === this); });
George
-
Apr 22, 2009
@
8:43 PM
Permalink
The other is the same as reported above: Every time I call the .mcDropdown(); function a click event is fired. I defined the function as:
.mcDropdown("#FolderMenu", {allowParentSelect: true, targetColumnSize: 1, select: function(value, display){mcDropdownSelect(this, value, display);}});
Appreciate any feedback. Really like the control.
Thanks,
George
George
-
Apr 22, 2009
@
8:47 PM
Permalink
I really don't understand your table cell isssue. One of the core design concepts of the plug-in was to have it calculate its size to so that it stays within the current viewport. So, limiting it to specific dimensions goes against the core concept.
Also, on your second issue, once again I'm afraid I don't really understand your issue.
Is there an live example of your problem I can see?
Dan G. Switzer, II
-
Apr 23, 2009
@
10:32 AM
Permalink
Event fire issue:
Turns out the event was firing correctly. It's not "click" event it's a "select" event and when I create a new instance of the control I call setValue()...
Width issue:
I get that this defeats one of your design goals but I need the width to be predictable and to fit into a limited space. I was able to get a fixed size on the dropdown - without having to modify any of the plug-in code - by setting the width on various elements when I create a new instance:
$(NewRow).find(".mcdropdown").width(150);
$(NewRow).find(".mcdropdown").find("input").width(150);
$(".tdFolderColumn").width(180);
The behavior when you mouse the control looks good - the popup is not limited in width so the user can see what they are selecting. But using keyboard entry you get a popup that is limited and so items may be hidden. Either way once an item is selected it may be too big to fully display in the closed dropdown. What I'd like to do is just try to scroll it to the right so that the final folder node is visible.
I'll try to put together an example page if I can sneak some time in this weekend.
George
-
Apr 24, 2009
@
11:33 AM
Permalink
Bellamy Benedetto Budiman
-
May 6, 2009
@
12:39 AM
Permalink
If you're using an input element for the input, just specify the input element's "value" attribute.
You could also use the setValue() after initializing the mcDropdown to specify a default value, but using the "value" attribute on the input element is the easiest and best solution.
Dan G. Switzer, II
-
May 6, 2009
@
8:05 AM
Permalink
I did and tried that earlier as well but for some reason it doesn't work on my end. I also tried redownloading the plugin and modify it on the sample page (by adding a default value to the input box). It doesn't work as well.
Here's the code I used to initialize the plugin:
$(document).ready(function (){
$("#cuisine").mcDropdown("#cuisinemenu",
{
targetColumnSize: 3,
}
);
$("#zone").mcDropdown("#zonemenu",
{
targetColumnSize: 3,
}
);
});
And here's the input box I use to attach the plugin:
<input type="text" name="cuisine" id="cuisine" value="Any Cuisine" />
<ul id="cuisinemenu" class="mcdropdown_menu">
<li rel="1">Any Cuisine</li>
<li rel="2">American (8)</li>
<li rel="3">Arabic (40)</li>
</ul>
and
<input type="text" name="zone" id="zone" value="Any Zone" />
<ul id="zonemenu" class="mcdropdown_menu">
<li rel="1">Any Zone</li>
<li rel="2">Airport (22)</li>
</ul>
Am I missing something? Thanks.
Bellamy Benedetto Budiman
-
May 6, 2009
@
9:20 AM
Permalink
The value should be "1" (whatever the "rel" attribute is.)
Dan G. Switzer, II
-
May 6, 2009
@
11:24 AM
Permalink
I can't believe I missed something so obvious :D. Thanks a lot! This sure saves me a lot of headaches.
Bellamy Benedetto Budiman
-
May 6, 2009
@
2:30 PM
Permalink
No problem--it happens to the best of us!
Dan G. Switzer, II
-
May 6, 2009
@
3:47 PM
Permalink
Richard Patt
-
May 7, 2009
@
3:10 PM
Permalink
No, I have done no work on this as it's not something I have a current need for and just haven't had time to look at adding the feature.
Dan G. Switzer, II
-
May 7, 2009
@
3:33 PM
Permalink
Bellamy Benedetto Budiman
-
May 11, 2009
@
12:44 AM
Permalink
There's no "reset" method, but you can just use the setValue() method to reset the value back to it's original state.
Dan G. Switzer, II
-
Oct 9, 2009
@
7:21 AM
Permalink
Dan G. Switzer, II
-
Oct 10, 2009
@
10:18 AM
Permalink
var dd = $("#style").mcDropdown();
dd.setValue("clear-style");
From Firebug:
Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy" code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location: "mysite.com/js/jquery-1.3.2.min.js Line: 12"
Error: thismenu.closeMenu is not a function
Source File: mysite.com/js/jquery.mcdropdown.js
Line: 124
Any thoughts? Thanks so much!!
It looks like an issue with jQuery v1.3.1 and v1.3.2, v1.3.0 works fine. From a quick troubleshooting session, it looks like for some reason v1.3.2 is firing an extra document.click event--which looks to be at least part of the culprit.
There doesn't seem to be a quick fix, so I'd recommend sticking with v1.2.6 for this page. I know they're working on a new jQuery update which perhaps will resolve the issue.
We're still on v1.2.6 due to issues we kept running into with v1.3.x.
Dan G. Switzer, II
-
Oct 21, 2009
@
8:36 AM
Permalink
Brian
-
Oct 21, 2009
@
11:14 AM
Permalink
This can be fixed by changing the line:
var $hidden = $divInput.find(":hidden");
to:
var $hidden = $divInput.find(":input");
I'll be releasing an update to this today.
Dan G. Switzer, II
-
Oct 29, 2009
@
10:05 AM
Permalink
http://www.givainc.com/labs/mcdropdown_jquery_plug...
Changes:
* Fixed capability issues with jQuery v1.3.1 and newer
* Fixed some CSS issues and reduced duplicate classes
* Fixed showACOnEmptyFocus behavior
* Fixed IE6 bgIframe behavior with small lists (now uses outerHeight())
* Fixed IE with using the mouse to put focus in the field (cause by input element having a transparent background)
Dan G. Switzer, II
-
Oct 29, 2009
@
3:55 PM
Permalink
how can i set a value in the mcDropDown field as page loads. I have its value like "menu:submenu" in session and when document is ready want to assign it to the field
Hasan
-
Dec 10, 2009
@
7:58 AM
Permalink
See this comment and read the next couple:
http://blog.pengoworks.com/index.cfm/2008/6/26/mcD...
You just need to set the value attribute of your form field to the matching rel attribute value.
Dan G. Switzer, II
-
Dec 10, 2009
@
8:24 AM
Permalink
$("#category").attr("value","1");
$("#category").mcDropdown("#list");
it doesn't work for me that way but if i do it in through input tag like
<input type="text" name="category" id="category" value="1"/>
It worked.
What m i missing?
Hasan
-
Dec 16, 2009
@
6:39 AM
Permalink
I recommend you read this page:
http://www.givainc.com/labs/mcdropdown_jquery_plug...
It will show you how to use the API to set the field via JS.
Dan G. Switzer, II
-
Dec 16, 2009
@
8:32 AM
Permalink
<code>
name=name.replace(/:/, "\<br \>");
</code>
but it is escaping the < & > to < and >
How can I stop it doing that escaping?
Thank you
Instead of modifying the code, I recommend using the "delim" option to change the character. You could change the delimiter to String.fromCharCode(10) (which is a line feed) and then use CSS to set white-space:pre on the field (so the carriage return shows.)
If you want to modify the source code, you're on your own. I've found it's just too difficult to support people who've modified the source. You're completely in your rights to do it, but you'll need to work out any issues you have on your own.
Dan G. Switzer, II
-
Dec 18, 2009
@
8:26 AM
Permalink
$(".mcdropdown a").append('<img src="'/images/down.gif"/>').hover(function(){
$(this).children().attr("src","/images/down-hover.gif");
},function() {
$(this).children().attr("src","/images/down.gif");
});
I removed the background images from the mcdropdown css, too, of course. I hope this saves someone time!
Harold Kyle
-
Dec 30, 2009
@
12:18 AM
Permalink
I don't speak englist very well. Please try to understand.
1,
"mcDropdown" When two or more than the same item....
If "mcDropdown" needed a mouse with a multiple choice problem can not be applied properly.
See a test page and I'll explain.
Test link : http://www.anjeuk.com/giva/sample_test.html
By using the keyboard when you select each item will work correctly.
However, using the mouse to select each item, the id = "category_one", id = "category_two" value is the same value that is selected.
When selecting items using the mouse ...
Each item you think about when choosing a keyboard like this has been applied to each of the selected value.
2,
"mcDropdown" finished selecting items, using the mouse or keyboard focus(cursor) is lost.
Using the keyboard(tab key) and then you can not progress.
please help me.
Matt Damon
-
Jan 20, 2010
@
7:36 AM
Permalink
You can't map the same UL list to multiple inputs. You need a 1-to-1 relationship.
Dan G. Switzer, II
-
Jan 20, 2010
@
11:18 AM
Permalink
the latest version of jquery or "jquery-1.3.1" since the operation using the keyboard down arrow does not work correctly.
However, "jquery-1.3.0" is earlier, the normal operation.
Test page please see the link below.
How can you solve this?
please help me.
test1 -> jquery-1.2.6 ~ jquery-1.3.0 => keyboard down arrow Normal Operation
link : http://www.anjeuk.com/giva/jquery-1.3.0.gettingsta...
test2 -> jquery-1.3.1 ~ jquery-1.4.1 => keyboard down arrow Does not work
link : http://www.anjeuk.com/giva/jquery-1.4.1.gettingsta...
Matt Damon
-
Jan 31, 2010
@
3:21 AM
Permalink

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