top of page

WIX 數據庫搜索系統構建 ・ ・ ・ ③

​顯示所有項目的程序代碼

從'wix-data'導入wixData;

 

讓 debounceTimer;

 

$w.onReady(函數(){

 

   $ w ("# dataset1"). onReady (() => {

     let count = $w("#dataset1").getTotalCount();

     $ w ("# totalText"). text ='Total:' + count;

 

     $ w ("# companyRepeater"). onItemReady (($ item, itemData, index) => {

       $ item ("# companyNameText"). text = itemData.title;

       $ item ("#gyoText").text = itemData.kubun;

       $ item ("#areaText").text = itemData.area;

       $ item ("#naiyoText").Text = itemData.Company_profile;

       $ item ("#companyImage").src = itemData.image01;  

       $ item ("# companyImage"). tooltip = itemData.title;  

       $ item ("# companyImage").link = itemData.url;

     });

   });

 

});

 

讓 lastFilterName;

 

異步函數過濾器(標題){  

 

  如果(最後一個過濾器名稱!== 標題){

    讓 newFilter = wixData.filter();

 

    如果(標題)

     newFilter = newFilter.contains('title', title);

     

     await $ w("#dataset1").setFilter(newFilter);

     

     let count = $w("#dataset1").getTotalCount();

     $ w ("# totalText"). text ='Total:' + count;

    設置變量(標題);

    }

}

 

函數 setVariables(標題){

   lastFilterName = 標題;

 

}

​輸入搜索程序代碼

從'wix-data'導入wixData;

 

讓 debounceTimer;

 

$w.onReady(函數(){

 

   $ w ("# dataset1"). onReady (() => {

     let count = $w("#dataset1").getTotalCount();

     $ w ("# totalText"). text ='Total:' + count;

 

     $ w ("# companyRepeater"). onItemReady (($ item, itemData, index) => {

       $ item ("# companyNameText"). text = itemData.title;

       $ item ("#gyoText").text = itemData.kubun;

       $ item ("#areaText").text = itemData.area;

       $ item ("#naiyoText").Text = itemData.Company_profile;

       $ item ("#companyImage").src = itemData.image01;  

       $ item ("# companyImage"). tooltip = itemData.title;  

       $ item ("# companyImage").link = itemData.url;

     });

   });

 

   $ w ("#searchInput"). onKeyPress ((事件) => {

    如果(去抖動定時器){

       clearTimeout (debounceTimer);

       debounceTimer = 未定義;

     }

 

     debounceTimer = setTimeout (() => {

       filter($w("#searchInput").value);

     }, 350);  

   });

   

   $ w ("#refreshButton"). onClick ((事件) => {

    篩選 ();

 

     $ w ("#searchInput"). value = undefined;

   });

 

});

 

讓 lastFilterName;

 

異步函數過濾器(標題){  

 

  如果(最後一個過濾器名稱!== 標題){

    讓 newFilter = wixData.filter();

 

    如果(標題)

     newFilter = newFilter.contains('title', title);

     

     await $ w("#dataset1").setFilter(newFilter);

     

     let count = $w("#dataset1").getTotalCount();

     $ w ("# totalText"). text ='Total:' + count;

    設置變量(標題);

    }

}

 

函數 setVariables(標題){

   lastFilterName = 標題;

 

}

bottom of page