Reputation: 7175
I have a block of html code in variable card in js file.I caught regular expression not match in card variable error.All single and double quotes matches.What I did wrong in html block.Is any typo error.
(function ($) {
Drupal.behaviors.one_time_popup = {
attach: function (context, settings) {
var celeType=Drupal.settings.one_time_popup.celeType;
card="<div class=\'cardTemplate-aniv\'>
<p class=\'bir-anniv-wishes\'>Happy Birthday and Successful Anniversary</p>
<p id=\'aspirian-name\'>"+userName+"</p>
<img src=\'"+Drupal.settings.publicpath+"/Birthday_Images/birthdayTemplate1.jpg\' style=\'width:250px;height:230px;\'>
<img src=\'"+Drupal.settings.publicpath+"/Anniversary_Images/"+anniversaryCount+"Anniversary.jpg\' style=\'width:250px;height:250px;\'>
</div>";
}
};
}(jQuery));
I have one more temmplate
cardTemplate1 = "<div class=\'cardTemplate\'><span class=\'birthdayImage\'></span><p class=\'wishes\'>Happy Birthday <span id=\'aspirian-name\'>"+userName+"</span> !</p><img src=\'"+Drupal.settings.publicpath+"/Birthday_Images/birthdayTemplate1.jpg\'></div>";
which shows regular expression mismatch without escape single quotes
Upvotes: 0
Views: 52
Reputation: 7544
You can't have multiline string literals in double quotes. If you have ES6 you can use backticks to have a multiline template string. See creating-multiline-strings-in-javascript
Upvotes: 1