Comma Seperated Tags List Walker Feature
Commit adds support of adding a list with commas to the tag field.
This commit is contained in:
parent
e8cfad9241
commit
b0013d5d2c
1 changed files with 20 additions and 7 deletions
|
@ -807,19 +807,32 @@
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
let addToTagList = function (value) {
|
||||||
$('#addTag').keypress(function(e) {
|
// trim
|
||||||
if (e.which == 13) {
|
value = value.replace(/^\s+|\s+$/g,"");
|
||||||
var value = $(this).val();
|
|
||||||
if ($("#tags option[value='" + value + "']").length > 0) {
|
if ($("#tags option[value='" + value + "']").length > 0) {
|
||||||
$("#tags option[value='" + value + "']").prop('selected', true);
|
$("#tags option[value='" + value + "']").prop('selected', true);
|
||||||
} else {
|
} else {
|
||||||
$('#tags').prepend($('<option>', {
|
$('#tags').prepend($('<option>', {
|
||||||
value: $(this).val(),
|
value: value,
|
||||||
text: $(this).val(),
|
text: value,
|
||||||
selected: true
|
selected: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#addTag').keypress(function(e) {
|
||||||
|
if (e.which == 13) {
|
||||||
|
var value = $(this).val();
|
||||||
|
// Split input?
|
||||||
|
if (value.indexOf(',') > -1) {
|
||||||
|
value.split(',').forEach( function(s) {
|
||||||
|
addToTagList(s);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addToTagList(value);
|
||||||
|
}
|
||||||
$(this).val('');
|
$(this).val('');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue