-1

I'm attempting to append this to my jQuery Mobile Listview. The append works correctly, however when a user clicks on the listview, triggering goToSurveyResults, it thinks that the third parameter in this function is a reference to a variable name, when in fact I simple want the string literal name. So for example, if my function is goToResults(1,2,dog), then it thinks dog is a reference to a variable. Is there a way to make javascript acknowledge that it is in fact not a variable name but a string??

$('ul#myList').append('<li><a href="javascript:void(goToResults(' + listOfSubjects[i].id + ',' + listOfSubjects[i].numberOfSubjects + ',' + listOfSubjects[i].name + '));"><h1>title<h1></li>
0

1 Answer 1

1

Try adding escaped quotes around your string value parameter like:

$('ul#myList').append('<li><a href="javascript:void(goToResults(' + listOfSubjects[i].id + ',' + listOfSubjects[i].numberOfSubjects + ',\'' + listOfSubjects[i].name + '\'));"><h1>title<h1></li>');

Example of the code working: http://jsfiddle.net/nqnpv/1/

Sign up to request clarification or add additional context in comments.

2 Comments

thank you so much. The issue was actually in the definition of my function. Changing my function to window.FunctionName is actually what did it...the escaped quotes actually did nothing!
just want to let you know that I just created another stackoverflow account so I could upvote you twice :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.