我在js文件中获取了drupal值。我想在html模板中传递变量。我想要包含' anniversaryCount'到html template.Now我抓到了
Uncaught SyntaxError:无效的正则表达式:/ (^|。)cbox(。| $)/:堆栈溢出 在RegExp.test()
(function ($) {
Drupal.behaviors.one_time_popup = {
attach: function (context, settings) {
var anniversaryCount = Drupal.settings.one_time_popup.aniv;
console.log(anniversaryCount); //prints correct value
cardTemplate = "<div class='cardTemplate'><span class='birthdayImage'></span><p class='wishes'>Happy Work Anniversary <span id='spl_name'></span> !</p><img src='" + Drupal.settings.publicpath + "/Anniversary_Images/" + anniversaryCount + "Anniversary.jpg'></div>";
}
};
}(jQuery));
答案 0 :(得分:0)
使用jquery将你的html放入页面
$(&#34;#your_elemen_id_where_to_put_html&#34)的HTML(cardTemplate);