0

just wondering if its possible to format code whilst using the append() function.

Im creating a form with JSON and jQuery but this form will be quite large and Its going to be annoying to work on one long line of code... so instead of:

$('<div id="admin-overlay-login"></div><form class="editUserDetails-form" action="admin/process/saveUserDetails.php">Editing Details for User:'+response.username+' , User ID:'+response.userID+'</form>').appendTo('body');

Is it possible to somehow do similiar to:

$('<div id="admin-overlay-login"></div>
  <form class="editUserDetails-form" action="admin/process/saveUserDetails.php">
    Editing Details for User:'+response.username+' , User ID:'+response.userID+'
  </form>').appendTo('body');

I know the above will break the code and wont work. But surely theres a way to do what im asking? Unless HOW im doing it is correct / frowned upon :)

Craig.

Lovelock
  • 7,689
  • 19
  • 86
  • 186
  • 1
    Check this: http://stackoverflow.com/questions/508269/how-do-i-break-a-string-across-more-than-one-line-of-code-in-javascript – Xaver Aug 16 '14 at 11:02
  • Thanks for that! Didn't think about asking for breaking lines. Craig. – Lovelock Aug 16 '14 at 11:03

1 Answers1

0

You can say like bellow

$('<div id="admin-overlay-login"></div>\
  <form class="editUserDetails-form" action="admin/process/saveUserDetails.php">\
    Editing Details for User:'+response.username+' , User ID:'+response.userID+'\
  </form>').appendTo('body');
Mritunjay
  • 25,338
  • 7
  • 55
  • 68