0

I am trying to show a link as a dropdown if it corresponds to the parent category. I checked the values and they are coming in correct but for some reason the if condition isn't returning true. This line is the issue: if(link.id == subLink.category).

ul.nav.navbar-nav.navbar-left
    each link in navLinks
        if(link.dropdown)
            li(class=(section == link.key ? 'active dropdown' : 'dropdown'))
                a(class=('dropdown-toggle'), href=('#{link.href}'), data-toggle=('dropdown'))= link.label
                ul(class=('dropdown-menu'), role=('menu'), aria-labelledby=('dropdownMenu'))
                each subLink in navSublinks
                    if(link.id == subLink.category)
                        li
                            a(href='#{subLink.url}')= subLink.category
         else
              // not a dropdown
user1572796
  • 1,057
  • 2
  • 21
  • 46
  • Can you post the List definitions of both `link` and `subLink`? These will be helpful to determine the root of your problem. – JME Aug 04 '14 at 04:49

1 Answers1

0

Something like this will fix this issue:

-var linkId = JSON.stringify(link.id)
-var sublinkCat = JSON.stringify(subLink.category)
each subLink in navSublinks
    if(linkId === sublinkCat)
        ....

The issue was trying to compare values of two objects, so first they need to be parsed into strings.

user1572796
  • 1,057
  • 2
  • 21
  • 46