I have this code :
var closeButton = $("<a class='close'/>") .button({ icons: { primary: "ui-icon-close" }, text: false }) .removeClass("ui-corner-all") .addClass("ui-corner-right ui-combobox-toggle") .click(function () { if (invisibleElement != null) jQuery(invisibleElement).val(""); //removing the close button with placaholder value jQuery(visibleElement).val("Select"); jQuery(visibleElement).focus(); jQuery(visibleElement).blur(); var parentNode = $(this).parent(); parentNode.find(this).remove(); isCloseButton = false; }); And I am adding this button conditionally by this:
$(visibleElement).parent().find(".showAll").after(closeButton); This is not added by default. This is added based on some input.
These things are added within a td
<table border="0" width="100%" cellspacing='0' cellpadding='2'> <tr> <td style="vertical-align:middle; text-align:left; width: 45%;"> <input type="text" id="theVisibleElement" value=""/> </td> </tr> But After adding the closeButton, I am not able to see the showAll element. Only the inputBox(visibleElement) and the closeButton is visible. Although, in the source code all three are there i.e visibleElement(the input TextBox), showAll element and closeButton. Strangely the td is enough big but still all three are not shown up. What to do? Any suggestion?
This is the jsfiddle: http://jsfiddle.net/8U6xq/1/ Though it's a bit messy.
if (jQuery.trim($(invisibleElement).val()).length > 0 && jQuery.trim($(invisibleElement).val()) != "0")will always be false because it is done only once when the element is created.selectevent ofautocomplete.