代码之家  ›  专栏  ›  技术社区  ›  Sree

触发器liszt:更新时未显示图像

  •  1
  • Sree  · 技术社区  · 11 年前

    Output

    我正在使用 chosenImage 插件。当我触发时 liszt:updated 它不会在列表中显示图像。

    剧本

    <script type="text/javascript"> 
      $(".my-select").chosenImage({
        disable_search_threshold: 10 
      });
    
      // some code that adding/removing options in select
    
       $('#my-select').trigger('liszt:updated'); 
    </script>
    

    HTML格式

    <select class="my-select" id="my-select" style="width:350px;" tabindex="2">
      <option data-img-src="chosenImage/flag-red.gif">Project A</option> 
      <option data-img-src="chosenImage/flag-purple.gif">Project B</option> 
    </select>
    

    有什么解决方案吗?提前感谢。

    1 回复  |  直到 11 年前
        1
  •  2
  •   shobhit shukla    11 年前

    根据示例中的代码,您不需要 $('#my-select').trigger('liszt:updated');

    只有这样才能奏效

    $(".my-select").chosenImage({
      disable_search_threshold: 10 
    });
    

    这应该行得通

      $('#my-select').trigger('liszt:updated'); 
      $(".my-select").chosenImage();
    

    只需在更新列表后调用chosenImage()方法