Last active
December 27, 2016 23:51
-
-
Save zeroef/f179a89852b0fa6533d9aae32e672a07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| qData = [{'id':'73','foo':'bar'},{'id':'45','foo':'bar'}, etc.] | |
| qData = [<%=QuestionjScript%>]; | |
| function setHelp(int questionId){ | |
| var result = $.grep(qData, function(e){ return e.id == questionId; }); | |
| if (result.length == 0) { | |
| // not found | |
| } else if (result.length == 1) { | |
| // access the foo property using result[0].foo | |
| //set the html for the help section here: | |
| span.val() = result[0].description; //or whatevs code is running it right now | |
| } else { | |
| // multiple items found | |
| } | |
| } | |
| /////////////////// | |
| // to create the list to pass to the front end | |
| var QuestionjScript = questions.Select(q => $"{{id:\{q.Id}, description:\"{q.Description\"}}}").ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment