Reputation: 682
I am using jQuery tags script http://textextjs.com/
The problem i am encountering is when the data is saved and then retrieved from my database. I can't get new tags to append or saved tags to display properly. Below is my code:
<input class="span8" id="tagname" placeholder="Enter A Tag" type="text">
<button id="addtag" type="button">Add</button>
<form method="post" action="classes/update.affid.php">
<input type="hidden" name="action" value="update_user_tags" />
<textarea id="textarea" name="tags" rows="1">
<?php echo $edituser->getField('tags');?>
</textarea>
<input type="submit" value="Save Tags">
</form>
<script type="text/javascript">
$('#textarea').textext({ plugins: 'tags' });
$('#addtag').bind('click', function(e)
{
$('#textarea').textext()[0].tags().addTags([ $('#tagname').val() ]);
$('#tagname').val('');
});
</script>
Everything works fine on first load. Once i save the data to the DB it is now displayed like:
["one","two","three","four","five"]
Then if remove the data and save, i get:
[]
How do i get the textext plugin to run run on the textarea properly?
Upvotes: 1
Views: 735