我開發了一個名爲premium carousel的小部件。在那裏,我使用從Elementor庫加載的carousel項目的select2設置字段。當在Elementor Libray中發佈模板並刷新輪播編輯器頁面時,該發佈的模板將填充到該select2設置字段中。使用jquery選擇Elementor插件的設置項
在編輯頁面中,我保存模板,那麼該模板不會直接填充。爲了解決這個問題,我使用了jquery ajax。但問題是「在單擊保存模板按鈕後,在成功功能中,我無法在要添加新項目的位置選擇該選擇字段。」
我試過這種方式檢查
(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);
我怎樣才能擺脫這個問題的?請任何想法嗎?
通過ID做...'$( '#elementor控制默認-c369')。CSS( '寬' ,'60px!important');' –
此ID在不同的輪播小部件上以及編輯器每次打開時都會更改。這個ID不適合我。也使用鉻的控制檯工具,我試過了,但沒有使用@AlessandroL。 –
可以更改選擇類嗎?例如:'elementor-select2'類可以改變嗎? –