Note that there are some explanatory texts on larger screens.

plurals
  1. POno css formatting in jquery listview ajax
    primarykey
    data
    text
    <p>I am fairly new to jquery all together. Basically what I have done is made a dynamic gallery populated from images retrieved from an ajax call. The images are appended to a unordered list and supposed to receive special css formatting specific to the image gallery, other ul lists are untouched. Everything works great, however when I view the gallery, the proper css formatting is not rendered on the images. I have searched all over stackoverflow and tried many of the options presented to similar problems including <strong>.listview('refresh');</strong> and after an ajax <strong>complete:</strong> as well as some other solutions. Nothing is working. If I navigate away from the page and come back, the formatting is applied. Here is the following code I am working with.</p> <p><strong>Link to Gallery</strong></p> <pre><code>$('ul#fieldList').append('&lt;li id="albums"&gt;&lt;a href="#Gallery1?" onClick="GetUserPhotos('+value.album_id+'); return false;"&gt;&lt;img src="images/1.jpg"&gt;&lt;h3&gt;'+value.name+'&lt;/h3&gt;&lt;p&gt;'+value.description+'&lt;/p&gt;&lt;/a&gt;&lt;div class="ui-li-count"&gt;'+value.count+' Images&lt;/div&gt;&lt;/li&gt;'); </code></pre> <p><strong>onClick Function</strong></p> <pre><code>function GetUserPhotos(albumid) { console.log("Get User Photos Function Ran"); var get_user_photos_album_id = albumid; var get_user_photos_client_id = window.localStorage.getItem("client_id"); var get_user_photos_user_id = window.localStorage.getItem("user_id"); console.log("Assign Variables from local storage"); var formData = { user_id: get_user_photos_user_id, client_id: get_user_photos_client_id, album_id: get_user_photos_album_id }; //Array $.ajax({ url: "client_photos.php", type: "POST", data: formData, async: "false", success: function (data) { $("ul#photosList li#photos").remove(); $("#test1").html(''); //data - response from server var PhotoData = $.parseJSON(data); console.log("PhotoData json data parsed"); $("ul#fieldList li#albums").remove(); $.each(PhotoData, function (key, value) { $('ul#photosList').append('&lt;li id="photos"&gt;&lt;a rel="' + value.album + '" href="http://www.myphotoshootapp.com/cms/uploads/' + value.client_id + '/' + value.album + '/' + value.id + '.' + value.ext + '" class="swipebox" title="' + value.fullname + '""&gt;&lt;img src="http://www.myphotoshootapp.com/cms/uploads/thumbs/' + value.client_id + '/' + value.album + '/' + value.id + '.' + value.ext + '" alt="' + value.fullname + '" /&gt;&lt;/a&gt;&lt;/li&gt;'); }); Swipe(); }, complete: function () { $('#ul#photosList').listview('create'); $.mobile.changePage("#Gallery1"); } }); } </code></pre> <p><strong>DIV Item's Are Added To</strong></p> <pre><code>&lt;div data-role="content"&gt; &lt;ul data-role="listview" data-inset="true" id="photosList"&gt; &lt;li id="title"&gt;Photos&lt;/li&gt; &lt;div class="main" id="test1"&gt;&lt;img src="images/ajax-loader.gif" alt="Loading..." /&gt;&lt;/div&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p><strong>And CSS</strong></p> <pre><code>li#photos { float: left !important; width: 33.33333333% !important; } li#photos a { display: block !important; margin: 5px !important; border: 1px solid #3c3c3c !important; } li#photos img { display: block !important; width: 100% !important; height: auto !important; } </code></pre> <p>As I said, I am pretty new to this and learning as I go, I have learned so much from reading a lot of other questions here but this one I can not figure out. Thanks for the help.</p> <p>On the first visit, a bunch of extra classes like ui-btn, ui-btn-icon-right, ui-li-has-arrow, ui-li, ui-li-has-thumb, ui-btn-up-c are being added and the second time, only my normal formatting is applied.</p> <p><strong>First Visit</strong> This image shows what the css formatting looks like on the first page visit Here's <a href="http://www.myphotoshootapp.com/json/css1.png" rel="nofollow">Image</a></p> <p><strong>Second Visit</strong> This image shows what the css formatting looks like when I return to the page (LIKE ITS SUPPOSED TO) Here's <a href="http://www.myphotoshootapp.com/json/css2.png" rel="nofollow">Image</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload