arielsalminen / TinyNav.js

Responsive navigation plugin that weighs just 443 bytes
http://tinynav.viljamis.com/
635 stars 207 forks source link

Cannot target selected option / no 'selected' class #71

Open BenRacicot opened 10 years ago

BenRacicot commented 10 years ago

Hey all, I've outfitted the code from grabbing the href to my data attributes instead and I've disabled the 'header away' function. However, I CANNOT figure out why the selected option does not get the 'selected' class so that I can target it and use my data attribute?! I've spent far too much time on this and hope the community will help guide me.

Thanks in advance.

Here is my changed code to grab the data attr:

 $nav
    .addClass('l_' + namespace_i)
    .find('a')
    .each(function () {
         options += '<option data-loc-subject="' + $(this).data('loc-subject') + '">';
         var j;
         for (j = 0; j < $(this).parents('ul, ol').length - 1; j++) {
            options += settings.indent;
          }
       options += $(this).text() + '</option>';
      });