Select Elementor插件的一个设置项使用jquery

Select an setting item of Elementor plugin using jquery

我开发了一个名为 premium carousel 的小部件。在那里,我为从 Elementor 库加载的轮播项目使用了 select2 设置字段。当模板在 Elementor Libray 中发布并刷新轮播编辑器页面时,该发布的模板将填充到该 select2 设置字段中。

在编辑器页面中,我保存了一个模板,然后不直接填充该模板。为了克服这个问题,我使用了 jquery ajax。但是问题是"After clicking the save template button, in success function I can not select that select field in where I want to append the new item."

我试过用这种方式检查

(function( $ ) {

    $(document).ready( function() {

    $('.elementor-control-premium_carousel_slider_content select[data-setting=premium_carousel_slider_content] ').css('width', '60px !important');
    // not selecting this element


    $('body').on('click', 'button#elementor-template-library-save-template-submit',
        { name:'elementor-control-premium_carousel_slider_content select[data-setting=premium_carousel_slider_content' }, function( event ) {
            console.log( $('.' + event.data.name ).length );
      // logs 0 which mean that element does not exists in document. Coming from another javascript code
    });
   });

})(jQuery);

我怎样才能摆脱这个问题?有什么想法吗?

请试试这个

$('.elementor-select2[data-setting=premium_carousel_slider_content]').each(function(index){
   alert($(this).html());
});

我会等你的反馈