Question

I try differents ways of passing variables from parent to child with jquery and I ve got some issues with text containing quote:

In the child popup I create some html element embedding a javascript calling method to the parent, one of the variable (label) is a string which can contains quote, If i try to display its content on the parent page, the string is cut after the first quote.

.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
  $('#grille_table').append( "<tr><td><img onclick=parent.updateFunction('"+ item.id +"',this.title,this.src); src=/uploads/Media/source/"+ item.image +" width=100 height=100 title='"+ item.label +"' />"+ item.label +"" );

How can achieve this ?

thx

Was it helpful?

Solution

I think you mean

.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
  $('#grille_table').append( 
   '<tr><td><img onclick="parent.updateFunction(\''+ 
  item.id +
  '\',this.title,this.src);" src="/uploads/Media/source/'+ 
  item.image +
  '" width="100" height="100" title="'+ 
  item.label +
  '" />'+ item.label);
}

OTHER TIPS

Have you tried to escape the quotes?

item.label.replace(/\"/g,"\\\"")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top