-1

In sweetalert, I prefer using html: instead of usual Sweetalert chaining for multiple fields. Main reason: sometimes the responsiveness on smaller screens goes haywire when chaining inputs.

Anyway, my question is in the html: option of sweetalert, I can't have the html string containing line breaks. I would simply do a php include to include a huge chunk of HTML

for example in sweetalert: the following is valid

html:'<h1>hello user</h1> WElcome ..blah blah blah',

but this is not valid:

html:'<h1>hello user</h1> 

WElcome ..blah blah blah',

How do I accomplish the 2nd part above please?

I realise that this probably a dumb newbie JavaScript question but please bear with me

Thanks

Rajan

Rajan
  • 15
  • 4

1 Answers1

0

Since ES6, you can use template string in javascript

html: `
<h1>Hello user</h1>
<p>
    welcome Blablabla...
</p>`
  • Thank you so much! But is the "`" character supported in some of the IE versions? I remember having an error with the most recent IE version (10 I think) before 11. I don't have access to it anymore. – Rajan Jul 26 '19 at 14:41
  • I thought about it and will do something really dumb and possibly stupid instead. I will store the long HTML in a separate file, read it in PHP using file() and then trim each item in the array and implode it to get one huge string. Uggggh… But then it will help those using IE 11 etc – Rajan Jul 26 '19 at 14:49
  • Unfortunately **template string** are not compatible with any version of IE. The other option is to concat your string with `+` – Yann AMSELLEM Jul 26 '19 at 14:51