jquery bootstrap selectpicker refreshing lists based upon previous list choice

前端 未结 5 1997
甜味超标
甜味超标 2020-12-28 12:38

I have three drop down lists, one list is populated on page load and doesn\'t change. The 2nd and 3rd lists may change depending on the selection. This functionality is wo

5条回答
  •  误落风尘
    2020-12-28 13:37

    What I understood from my experience with this so far -

    If you are adding dynamically options to the dropdown then you must need to call below function just before adding option

    $(".selectpicker").selectpicker();
    

    Once you completed adding options then call below function (if you are using ajax to add option then put this function into success part as just answered Athina)

    $('.selectpicker').selectpicker('refresh');
    

    If you are facing any weird issue like showing dropdown not data or sometime dropdown not showing properly then definitely you must have made mistake in placing about function and nothing else.

提交回复
热议问题