Skip to content

Commit

Permalink
- remove the added '[]' to the input name. This is needed by PHP and …
Browse files Browse the repository at this point in the history
…Ruby frameworks, not CherryPy.

- add the option 'with_icons' and default it to false. When true, an extra <span> is added to the list of choices in order to allow the addition of icons. The <span> will have a class equal to the value of element .
  • Loading branch information
eeabed committed Jan 21, 2011
1 parent d526db7 commit 00183fb
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions jquery.fcbkcomplete.js
Expand Up @@ -85,9 +85,9 @@ jQuery(function($) {
function createFCBK() {
element.hide();
element.attr("multiple", "multiple");
if (element.attr("name").indexOf("[]") == -1) {
/* if (element.attr("name").indexOf("[]") == -1) {
element.attr("name", element.attr("name") + "[]");
}
}*/

holder = $(document.createElement("ul"));
holder.attr("class", "holder");
Expand Down Expand Up @@ -160,27 +160,23 @@ jQuery(function($) {
if (!maxItems()) {
return false;
}
var li = document.createElement("li");
var txt = document.createTextNode(title);
var aclose = document.createElement("a");
var liclass = "bit-box" + (locked ? " locked": "");
$(li).attr({
"class": liclass,
"rel": value
});
$(li).prepend(txt);
$(aclose).attr({
"class": "closebutton",
"href": "#"
});

li.appendChild(aclose);
holder.append(li);

$(aclose).click(function() {
removeItem($(this).parent("li"));
return false;
var li = $('<li />', {
'class': liclass,
rel: value,
text: title
});
if (options.with_icons) {
li.prepend( $('<span />', {'class': value}));
}
li.append( $('<a />', {
'class': 'closebutton',
href: '#',
click: function() {
removeItem($(this).parent("li"));
return false;
}})
).appendTo(holder);

if (!preadded) {
$("#" + elemid + "_annoninput").remove();
Expand Down Expand Up @@ -390,7 +386,11 @@ jQuery(function($) {
//nothing here...
}
else{
content += '<li rel="' + object.value + '">' + itemIllumination(object.key, etext) + '</li>';
var icon = ''
if (options.with_icons) {
icon = '<span class="' + object.value + '"></span> '
}
content += '<li rel="' + object.value + '">' + icon + itemIllumination(object.key, etext) + '</li>';
counter++;
maximum--;
}
Expand Down Expand Up @@ -619,7 +619,8 @@ jQuery(function($) {
onselect: null,
onremove: null,
attachto: null,
delay: 350
delay: 350,
with_icons: false
},
opt);

Expand Down

0 comments on commit 00183fb

Please sign in to comment.