如何使用WIX中的复选框获取转发器数据?

问题描述

我正在显示数据库中的转发器数据。数据在转发器中完美显示

现在,我想在一个或多个中继器上选择“复选框”,但不起作用。

enter image description here

当我选中复选框时,它应该显示“ Air Jordan”。但是它显示“ Hydra”。而且索引值也不显示

enter image description here

这是我的代码

   export function checkBox1_change(event) {
 // Add your code for this event here: 

   let myid=$w('#text32').text;
  console.log(myid);
  $w("#repeater2").onItemReady( ($item,itemData,index) => {   

 if ($w("#checkBox1").checked) {
   console.log("index:"+index);
   } else {
   console.log("no Index");
   }   

   } );

解决方法

您需要像这样确定点击项的范围

export function checkbox1_change(event) {
   let $item = $w.at(event.context);
   let myid = $item('#text32').text;
   console.log(myid);
   /*Checkbox*/
   if($item("#checkbox1").checked){
      console.log("index:"+index);
   }else{
      console.log("no Index");
   }
}

在此处了解有关范围设定的更多信息:https://www.wix.com/corvid/forum/tips-tutorials-examples/removal-of-the-w-parameter-from-event-handlers