Sunday 15 August 2010

javascript - icanhaz/mustache loop (iterate through elements) js error -


I'm trying to do icanhaz / mustache loop, as defined in this and I get an error in the browser console Has been:

  Uncheck error: syntax error, unrecognized expression: & lt; Option value = "1" & gt; First & lt; / Option & gt; & Lt; Option value = "2" & gt; Second & lt; / Options & gt;   

I do not know why I noticed that this line is causing the problem:

  ich.myTemplate (listOfStuff);   

This is my complete code:

   gt; script type =" text / javascript "src =" http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js " & Gt; & lt; / script & gt; script type = "text / javascript" src = "https://raw.github.com/HenrikJoreteg/ICanHaz.js/master/ICanHaz.js" & gt; & Lt; / script & gt; & lt; / head & gt; & lt; body & gt; & lt; select id = "mySelectBox" & gt; & lt; / select & gt; & lt; script id = " MyTemplate "type =" text / html "& gt; {{#stuff}} & lt; option value =" {{key}} "& gt; {{desc}} & lt; / option & gt; {{/ Stuff}} & lt; / script & gt; & lt; script & gt; $ {Document} .ready (function () {var listOfStuff = {stuff: {{key: "1", Desc: "first"}, {key: "2", desc: "second"}}}; var x = Ich.myTemplate (listOfStuff); $ ("# mySelectBox"). Attachment (x);});   

Thanks for any suggestions!

Finally I got an error. This was a jquery version problem - 1.9.1 was returning error and was not 1.8.3. Compare those demos: 1.9.1 for version

  • - jquery 1.9.1
  • - jquery 1.8.3

    See on javascript console.

    In addition, if I

      & lt; Script id = "myTemplate" type = "text / html" & gt; {{#stuff}} & lt; Option value = "{{key}}" & gt; {{Desc}} & lt; / Options & gt; {{/ Stuff}} & lt; / Script & gt;   

      & lt; Script id = "myTemplate" type = "text / html" & gt; {{#stuff}} & lt; Option value = "{{key}}" & gt; {{Desc}} & lt; / Options & gt; {{/ Stuff}} & lt; / Script & gt; For 1.9.1   

    , it worked fine too.


    Edit: This is an open one if you wish, please help fix this bug!

No comments:

Post a Comment