Skip to content

Commit

Permalink
Use original id attribute for new input element
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbee committed Jun 20, 2013
1 parent c4663a8 commit 9864669
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions jquery.ddslick.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@
else options.data = $.merge(ddSelect, options.data);

//Replace HTML select with empty placeholder, keep the original
var original = obj, placeholder = $('<div id="' + obj.attr('id') + '"></div>');
var original = obj, placeholder = $('<div').attr('id', obj.attr('id') + '-dd-placeholder');
obj.replaceWith(placeholder);
obj = placeholder;

//Add classes and append ddSelectHtml & ddOptionsHtml to the container
obj.addClass('dd-container').append(ddSelectHtml).append(ddOptionsHtml);

// Inherit name attribute from original element
obj.find("input.dd-selected-value").attr("name", $(original).attr("name"))
obj.find("input.dd-selected-value")
.attr("id", $(original).attr("id"))
.attr("name", $(original).attr("name"));

//Get newly created ddOptions and ddSelect to manipulate
var ddSelect = obj.find('.dd-select'),
Expand Down

0 comments on commit 9864669

Please sign in to comment.