未应用 JQuery Mobile

标签 jquery css jquery-mobile jquery-mobile-fieldset jquery-mobile-slider

我在使用 JQueryMobile 时遇到了一些问题,因为我想实现一些小部件,但是小部件的主题和颜色没有很好地实现。

这是一张展示正在发生的事情的照片: enter image description here

例如,正确的小部件是:

enter image description here

如果我动态添加 jquerymobile 小部件,则主题没有很好地添加,但如果 html 已经在文件中(不是使用 javascript 动态添加),主题看起来很好。这是我用来添加小部件的代码:

function cesta_insert_html(){
    var cesta_bought = $('body').data('cesta_list');
    cesta_bought.forEach(function(element, index){
        image = get_product_info(element[0].id, 'data' + $('body').data('clicked_listview_item'));
        $('#cesta_view').append('<div data-role="collapsible-set" id="collapsible" data-theme="a" data-content-theme="c"><div data-role="collapsible" data-collapsed="false"><h3 id="title_collapsible">'+image.pname+'</h3><center><div id=image_cesta><img src=data:imajpeg;base64,'+image.pimage+' alt="image"></div><div data-role="fieldcontain"><fieldset data-role="controlgroup"><input type="range" class="slider" name="slider" value="0" min="0" max="100" data-highlight="false"></fieldset></div></center><div class="ui-grid-a"><div class="ui-block-a"><a id=SaveChangesCesta data-role="button" type="submit" >Guardar cambios</a></div><div class="ui-block-b"><a id="DeleteCesta" type="submit" >Eliminar de cesta</a></div></div></div></div><br><br>');
    });
}

谢谢!

最佳答案

工作示例:http://jsfiddle.net/Gajotres/6nG2n/

您正在组合几个不同的小部件,要增强它们的标记,您应该运行 trigger('create')。

在我的另一个答案中阅读更多相关信息: jQuery Mobile: Markup Enhancement of dynamically added content

$('[data-role="content"]').append('<div data-role="collapsible-set" id="collapsible" data-theme="a" data-content-theme="c"><div data-role="collapsible" data-collapsed="false"><h3 id="title_collapsible">Image</h3><center><div id=image_cesta><img src=data:imajpeg;base64,Image alt="image"></div><div data-role="fieldcontain"><fieldset data-role="controlgroup"><input type="range" class="slider" name="slider" value="0" min="0" max="100" data-highlight="false"></fieldset></div></center><div class="ui-grid-a"><div class="ui-block-a"><a id=SaveChangesCesta data-role="button" type="submit" >Guardar cambios</a></div><div class="ui-block-b"><a id="DeleteCesta" type="submit" >Eliminar de cesta</a></div></div></div></div><br><br>');   
$('#index').trigger('create');

关于未应用 JQuery Mobile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16569126/

相关文章:

jquery - 具有绝对位置的可点击区域

c# - Kendo UI 网格中的内联编辑?

javascript - 将事件放在事件中是否正确?

jquery - 单击提交时验证不起作用 : jquery

html - 如何解决三 Angular 形对齐问题,我不知道我的代码有什么问题

javascript - jQuery 淡入/淡出文本,然后淡入新文本

css - 如何在 Angular 6+ 中使 mat-form-field-underline 的高度为 0

javascript - 如何调试 PhoneGap 应用程序中的内存使用量攀升?

jquery-mobile - Phonegap 和 jquery mobile : a href -> Origin null is not allowed by Access-Control-Allow-Origin

html - jquery mobile 在 image1 和 image2 之间间隔