I am having an issue with Jquery TagIt. It is working fine, but when I pull the records form the database and display them using a foreach loop it displays the labels like they should but then adds an x at the end as text.
The second x is the only one that should be there which deletes the record. I have tried to remove the × but then nothing shows up at all. Even the input value returns an x after the text. I am not sure what I am doing wrong.
I have provided a picture to show you what I mean. Please me know if anything needs clarification. Thanks for any assistance.
<?php $my_dietary_requirements = explode(', ', $my_dietary_requirements); ?>
<fieldset class="edit-boxes">
<ul class="table-tags" id="my-diet">
<?php foreach($my_dietary_requirements as $diet){
echo '<li class="tagit-choice ui-widget-content ui-state-default ui-corner-all tagit-choice-editable">
<span class="tagit-label">'.$diet.'</span>
<a class="tagit-close">
<span class="text-icon">×</span>
<span class="ui-icon ui-icon-close"></span>
</a>
<input value="'.$diet.'" name="my_dietary_requirements[]" class="tagit-hidden-field" type="hidden">
</li>';
} ?>
</ul>
</fieldset>
//Javascript
//Dietary Requirements
$("#my-diet").tagit({
allowSpaces: true,
fieldName: 'my_dietary_requirements[]'
});
$('#my-diet .tagit-new input').attr('id','my-dietary-requirements');