Friday 15 February 2013

jquery - How to make a link, the text from object key and link href as object value.. using Handlebarsjs? -


I have such data in my object:

  naviObj = {"home": "Homilink", "Service": "Serial Link", "Contact": "Contact Link"}   

From this, I should make a link text with the key of the object and be a href The value of each key .. I tried this kind of ..

  naviObj = {"home": "homemail", "service": "serial link", "contact": " Contact link "} var naviMaker = function () {var naviHtml = handlar.com ($ (" #navigation ") .html ()); $ ("Neval ul") Append (nwhmtm (nawobj)); } Navy ();   

I think the result should be:

  & lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "homemail" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "serice link" & gt; Service & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "contactLink" & gt; Contact & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;   

I'm getting link text and object values ​​.. but I do not know about the key of the link's text ..

Any help to solve it For please ..?

here

I found an answer on Google search:: Still no one appreciates a small approach. Thank you.

Here's the solution. Jeffedley

HTML & lt; Ul & gt; & Lt; / Ul & gt;

script

  $ (function () {naviObj = {"home": "homemail", "service": ($ "UL") for "Serial Link", "Contact": "Contact Link"} ($ & Amp;; "+ Property +" & lt; / a & gt; & lt; / li & gt; ; ");}});    

No comments:

Post a Comment