materialize icon indicating copy to clipboard operation
materialize copied to clipboard

tabs with anchor tags with href having a slash following the hash causes an error

Open ancientdemon opened this issue 10 years ago • 6 comments

When anchor tags in tabs are defined with a forward slash ('/') following the hash ('#') like href='#/link' (this is an angular route) this causes an error at runtime.

image

The error seen in the console is as follows

Error: Syntax error, unrecognized expression: #/troubledAccountList at Function.ga.error (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:12481) at ga.tokenize (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:18408) at ga.select (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:21136) at Function.ga as find at n.fn.extend.find (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:23410) at n.fn.init (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:23954) at n (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:405) at HTMLAnchorElement. (http://localhost:9558/bower_components/materialize/dist/js/materialize.js:1236:9) at Function.n.extend.each (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:2882) at n.fn.n.each (http://localhost:9558/bower_components/jquery/dist/jquery.min.js:2:847) undefined

line that causes the error in materialize.js is

  // Hide the remaining content
  $links.not($active).each(function () {
    $(this.hash).hide();
  });

update: someone has asked the same question stackoverlfow

http://stackoverflow.com/questions/34986418/sliding-tab-indicator-of-materializecss-tab-disappears-on-adding-href-as-name

ancientdemon avatar Feb 28 '16 01:02 ancientdemon

+1 i think we can use data-href='#id' to replace href='#id'

Tk-archer avatar Feb 28 '16 16:02 Tk-archer

Thanks @Tk-archer , but I could not figure out how the navigation works upon clicking the tab when you use data-href='#id'. Now there is no error displayed in console but navigation does not work either. Could you kindly point to an example implementation?

ancientdemon avatar Feb 28 '16 17:02 ancientdemon

I was able to get rid of the error by commenting out 3 lines in materialize.js. Version 0.97.7. Line 1272, 1296, and 1323. It doesn't appear to have any effect on my app other than removing the error. I hope the devs look into this.

Here is my post on SO – http://stackoverflow.com/questions/39902673/jquery-syntax-error-unrecognized-expression-using-angular-angular-ui-router-an

itsmejustind avatar Oct 06 '16 21:10 itsmejustind

@Tk-archer is right. data-href="#/asdf" works for me. Working Fiddle – https://jsfiddle.net/whatisthebigpicture/rj08fosn/

itsmejustind avatar Oct 06 '16 21:10 itsmejustind

Closed due inactivity. Feel free to reopen it, if it's still necessary.

tomscholz avatar Jul 08 '17 10:07 tomscholz

This is not fixed. vue.js always generate href for router-link template element. so I created #5291 to fix this.

huww98 avatar Oct 22 '17 09:10 huww98