|
@@ -100,7 +100,6 @@ function createFilterHtml(item) {
|
|
|
|
|
|
// 清除單一篩選條件
|
|
|
function removeBtn(element, id, val) {
|
|
|
- console.log('id, val', id, val);
|
|
|
filterList = filterList.filter(item => item.text !== val);
|
|
|
|
|
|
; // 移除 div & active
|
|
@@ -155,7 +154,37 @@ async function designerSearch(type = "") {
|
|
|
let input = $(".keywords").val();
|
|
|
|
|
|
if (input !== "") {
|
|
|
- url += `&keyword=${input}`;
|
|
|
+ let isExist = filterList.some((item) => item.id === "keyword"); // 判斷是否已存在關鍵字
|
|
|
+
|
|
|
+ const newItem = {
|
|
|
+ id: "keyword",
|
|
|
+ text: "關鍵字",
|
|
|
+ value: input
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!isExist) {
|
|
|
+ filterList.push(newItem);
|
|
|
+ createFilterHtml(newItem);
|
|
|
+ } else {
|
|
|
+ // 移除原本關鍵字
|
|
|
+ $('.budget p.me-1').each(function () {
|
|
|
+ if ($(this).text().includes('關鍵字')) {
|
|
|
+ $(this).closest('.me-3').remove();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (filterList.length === 0) {
|
|
|
+ $('#removeResultBtn').hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ filterList = filterList.filter(item => item.text !== "關鍵字");
|
|
|
+
|
|
|
+ filterList.push(newItem);
|
|
|
+ createFilterHtml(newItem);
|
|
|
+
|
|
|
+ }
|
|
|
+ $(".keywords").val("")
|
|
|
+ // url += `&keyword=${input}`;
|
|
|
}
|
|
|
|
|
|
if (filterList.length) {
|