how to add Button to a select2 dropdown on a dynamic table

后端 未结 1 1063
北恋
北恋 2020-12-21 05:47

Good day!

I\'m doing a Dynamic table which you can add/remove row, and I\'m using select2 to search Items on the database via ajax and its working well at the moment,

相关标签:
1条回答
  • 2020-12-21 05:53

    In my case I just added this function

    formatNoMatches: function( term ) { 
    
              $('.select2-input').on('keyup', function(e) {
                 if(e.keyCode === 13) 
                   {
                    $("#modalAdd").modal();          
                    $(".select2-input").unbind( "keyup" );
                   }
              });
    
            return "<li class='select2-no-results'>"+"No results found.<button class='btn btn-success pull-right btn-xs' onClick='modal()'>Add New Item</button></li>";
            }
    
    0 讨论(0)
提交回复
热议问题