Page 1 of 1

Dynamic Breadcrumbs Need

Posted: 24 Apr 2016, 16:39
by bdking
Hi, I am trying implement a dynamic breadcrumbs for Volt theme. But I am facing several problems. I am trying to use Jquery to read menuitem value like bellow:
<div class="breadcrumb">
<div class="item"><a href="#home">Home / </a></div>
</div>
And Mainly JS is:

$('.items a').on('click', function() {
var $this = $(this),
$bc = $('<div class="item"></div>');

$this.parents('li').each(function(n, li) {
var $a = $(li).children('a').clone();
$bc.prepend(' / ', $a);
});
$('.breadcrumb').html( $bc.prepend('<a href="#home">Home</a>') );
return false;
})

It works nice and displays menu value dynamically, But problem is this, when I click menuitem that contain action and then page reloads and clear the breadcrumbs.

Please advise. Any idea.

Re: Dynamic Breadcrumbs Need

Posted: 25 Apr 2016, 12:47
by mert.sincan
I think you can use jquery cookie plugin to restore item. You can add item list of breadcrumb into cookie array then you can create <li>, <a> and append them into breadcrumb component after loading page. I think these links can help to you;
http://stackoverflow.com/questions/9040 ... ery-cookie
http://stackoverflow.com/questions/1959 ... ery-cookie
http://stackoverflow.com/questions/1458 ... ith-jquery

Exp;

Code: Select all

var cookieArray=[]

$(window).load(function()) {
   if(cookieArray.length) {
      /* create items from cookieArray */
   }

   $('.items a').on('click', function() { 
       /* push item value or ...  to cookieArray */ 
   });
   // Other actions 
}

Re: Dynamic Breadcrumbs Need

Posted: 27 Apr 2016, 06:37
by bdking
@aragorn Thank you very much for your favor. I have already solved the issue identifying click and repeat click after 300 miliseconds, now it is working fine. But your advice is better than my solutions.

Re: Dynamic Breadcrumbs Need

Posted: 27 Apr 2016, 09:16
by mert.sincan
Glad to hear that you solved the problem, thanks for the update ;)

Re: Dynamic Breadcrumbs Need

Posted: 27 Apr 2016, 09:28
by bdking
aragorn wrote:Glad to hear that you solved the problem, thanks for the update ;)
:D

Re: Dynamic Breadcrumbs Need

Posted: 27 Apr 2016, 09:30
by mert.sincan
:D