jQuery Mobile al crear un conjunto plegable dinámicamente a través de ajax no aplica estilo [duplicado]

Posible duplicado:
Adición dinámica de elementos plegables

I am dynamically creating a Collapsible set and adding it to the page using $('#myID').html(htmlcode). The styling is not being applied to the page. How can I get jQUery mobile to apply it styling?

(Estoy usando $.get() to query a web service.The content that returned I am looping through to create the markup)

preguntado el 27 de agosto de 11 a las 23:08

Hey, nice question. Do you already have found a solution to this? Thanks -

4 Respuestas

This is working for me. My ajax returns a bunch of h3's which I insert into a collapsible div and append a p tag for the content.

$(document).ready(function(){

    $.get(my_url, function(data) {
        var content = $('div[data-role="content"]').html(data);
        $('h3').each(function(h3_element) {
            var coll = $('<div class="ui-collapsible-contain" name="blog"  data-role="collapsible" data-collapsed="true">');
            coll.append($(this));
            coll.append($('<p>'));
            content.append(coll);
        });
        content.trigger( "create" );        
    });

});

Respondido 14 Feb 12, 15:02

and no, refresh trigger didn't work either... - Bjorn

Ya respondido en Jquery Mobile Collapsible Content

To initialize your div correctly after preventing the default init formating, you'll have to use something like $("a way to select your div").trigger('create'); as specified here: http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.html

contestado el 23 de mayo de 17 a las 12:05

$content.find(":jqmData(role=collapsible)").collapsible();

Respondido el 26 de enero de 12 a las 14:01

This was how my team was doing it at first, but it caused problems with the styling when performed on a collapsible-set así como la collapsibles inside. Using .trigger('create') arreglado. - Limón

Respondido 20 Oct 11, 12:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.