ndabas / toc

Table of Contents jQuery Plugin - A minimal, tiny jQuery plugin that will generate a table of contents, drawing from headings on the page.
https://ndabas.github.io/toc/
Apache License 2.0
84 stars 24 forks source link

Make toc links friendly to angularjs - add target="_self" #5

Closed prasad83 closed 9 years ago

prasad83 commented 9 years ago

Angularjs adds "/" to hash tags having # by default, adding target helps for self-referencing links on the page.

// Add the list item
$("<li/>").appendTo(stack[0]).append(
    $("<a/>").text(elem.text()).attr("href", "#" + elem.attr("id")).attr("target", "_self")
);
</pre>
ndabas commented 9 years ago

target="_self" is the default. If another library or framework changes that behavior, you need to handle that elsewhere.

This is not an issue with the toc plugin.