3

I'm trying to implement this nav bar on my Yesod web app. My question how should I call a hamlet file from the javascript?

.....
.....
var Tabs = {
    'Tab one'   : 'pages/page1.html',
    'Tab two'   : 'pages/page2.html',
    'Tab three' : 'pages/page3.html',
    'Tab four'  : 'pages/page4.html'
}
.....
.....

As you can see it's calling the html pages with relative pathing, how do I do something like $(widgetFile "mypage")?or @{MyPageControllerR}?

HHC
  • 2,513
  • 2
  • 18
  • 26

1 Answers1

2

I suggest to you write as html

<ul>
    <li>
      <a href="@{...}" ...

You can write as javascript using julius, in that case some like

var Tabs = {
    'Tab one'   : '@{MyPageController1R}',
    'Tab two'   : '@{MyPageController2R}',
    'Tab three' : '@{MyPageController3R}',
    'Tab four'  : '@{MyPageController4R}'
}
josejuan
  • 9,338
  • 24
  • 31
  • Thanks, I tried it out and the second is what I want, delighted that even in javascript we can have type safety! – HHC Jun 13 '13 at 11:53