Skip to content

Instantly share code, notes, and snippets.

@zeroef
Last active December 27, 2016 23:51
Show Gist options
  • Select an option

  • Save zeroef/f179a89852b0fa6533d9aae32e672a07 to your computer and use it in GitHub Desktop.

Select an option

Save zeroef/f179a89852b0fa6533d9aae32e672a07 to your computer and use it in GitHub Desktop.
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