Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display this next and prev title in url with bbq and jquery
    primarykey
    data
    text
    <p>any one can help me i have gallery and every li has data-title, i want to add that value to url, im trying with no luck its always saying undefined, but i have post id and i easily added that to url. any one knows how to pass that data-title attribute to url.</p> <pre><code> function getPhoto(postId, hasSelector) { //first visible value var title = jQuery(this).children("li").attr("data-title"); var next = jQuery('#gallery-wrap li.visible').first().attr('id').split('photo-')[1]; var next_title = jQuery('#gallery-wrap li.visible').first().attr('data-title')[1]; //last visible value var prev = jQuery('#gallery-wrap li.visible').last().attr('id').split('photo-')[1]; var prev_title = jQuery('#gallery-wrap li.visible').last().attr('data-title')[1]; //has next var var hasNext = jQuery(hasSelector).parent().next(); //has prev var var hasPrev = jQuery(hasSelector).parent().prev(); //if there is a next object if(hasNext.length != 0) { while(hasNext.hasClass('visible') == false &amp;&amp; hasNext.length != 0) { hasNext = hasNext.next(); } if(hasNext.length != 0) { var next = hasNext.attr('id').split('photo-')[1]; var next_title = hasNext.attr('data-title')[1]; } } //if there is a previous object if(hasPrev.length != 0) { while(hasPrev.hasClass('visible') == false &amp;&amp; hasPrev.length != 0) { hasPrev = hasPrev.prev(); } if(hasPrev.length != 0) { var prev = hasPrev.attr('id').split('photo-')[1]; var prev_title = hasPrev.attr('data-title')[1]; } } // prev ids and post ids of photo var _this = jQuery('#photo-'+postId); var prevIds = []; var nextIds = []; var nextTitle = []; var prevTitle = []; var newTitle = []; var nextLi = _this.next(); while (nextLi.length != 0 &amp;&amp; nextLi.hasClass('visible')) { nextIds.push(nextLi.attr('id').split('photo-')[1]); nextLi = nextLi.next(); if (nextIds.length &gt;= 5) { break; } } var prevLi = _this.prev(); while (prevLi.length != 0 &amp;&amp; prevLi.hasClass('visible')) { prevIds.unshift(prevLi.attr('id').split('photo-')[1]); prevLi = prevLi.prev(); if (prevIds.length &gt;= 5) { break; } } jQuery('#loader').fadeIn(200, function() { jQuery.ajax({ url: jQuery('#theme-url').attr('data-id'), data: {id : postId, next : next, prev : prev, prev_ids: prevIds, next_ids: nextIds, nextTitle: next_title, prevTitle:prev_title, title:newTitle }, success: function(data) { var gallery = jQuery('#gallery-overlay'); gallery.html(data); jQuery('#next-post').attr('data-id', next); jQuery('body').css({overflow: 'hidden'}); jQuery('#gallery-overlay, #body-overlay').fadeIn(500, function () { jQuery('#loader').fadeOut(500); }); //re-initialize the gallery galleryInit(); var url = postId; var sTit = title if(url) {// require a URL window.location.hash = url + sTit; } } }); }); } </code></pre> <p>here is html code</p> <pre><code>&lt;div id="gallery-wrap" class="clearfix"&gt; &lt;ul class="large-grid"&gt; &lt;li id="photo-417" class="term-9 visible"&gt; &lt;a href="url" class="singleLightbox" data-title="data-title"&gt; &lt;img" src="img" class="attachment-large-grid wp-post-image" alt="fotografia ślubna sesja nad polskim morzem" title="title" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="photo-333" class="term-4 visible"&gt; &lt;a href="url" class="singleLightbox" data-title="data-title"&gt; &lt;img src="img" class="attachment-large-grid wp-post-image" alt="sesja z trzymiesięcznym dzieckiem" title="title" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre>
    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