简体   繁体   English

Drupal从JavaScript变量中删除我的封闭div标签

[英]Drupal stripping my closing div tags from a JavaScript variable

I'm trying to style a Google Maps InfoWindow. 我正在尝试设置Google Maps InfoWindow的样式。 For each of my map markers I have a window that works perfectly on a local site and in a JSFiddle. 对于我的每个地图标记,我都有一个窗口,该窗口可以在本地站点和JSFiddle中完美运行。 However, when I add the code to a Drupal block, it strips the closing div tags. 但是,当我将代码添加到Drupal块时,它会剥离结束的div标签。

I've tried this way: 我已经尝试过这种方式:

`var message = 
"<div class='window-container'>" +
  "<div class='window-content'>" +
    "<div class='window-header'>" +
      "<div class='window-title'>" + name + "</div>" +
      "<div class='window-subtitle'>" + org + "</div>" +
    "</div>" +
    "<div class='window-body'>" + summary + "...</div>" + 
  "</div>" +
"</div>";`

And this way: 这样:

`var message =
'<div class="window-container">\
  <div class="window-content">\
    <div class="window-header">\
      <div class="window-title">' +name+ '</div>\
      <div class="window-subtitle">' +org+ '</div>\
    </div>\
    <div class="window-body">' +summary+ '</div>\
  </div>\
</div>';`

And this way with a Babel compiler: 然后用Babel编译器:

`var message = '
  <div class="window-container">
    <div class="window-content">
      <div class="window-header">
        <div class="window-title">${name}</div>
        <div class="window-subtitle">${org}</div>
      </div>
      <div class="window-body">${summary}</div>
    </div>
  </div>'`

And on the page, in my console, it always comes out like this! 在页面上,在我的控制台中,它总是这样显示!

`var message = 
"<div class='window-container'>" +
  "<div class='window-content'>" +
    "<div class='window-header'>" +
      "<div class='window-title'>" + name + "" +
      "<div class='window-subtitle'>" + org + "" +
    "" +
    "<div class='window-body'>" + summary + "..." + 
  "" +
"";`

It removes all the closing div tags! 它将删除所有关闭的div标签! Why? 为什么?

If you paste your code into ckeditor or other filters you'll have some trouble like that. 如果将代码粘贴到ckeditor或其他过滤器中,将会遇到类似的麻烦。

So it's recommanded to create a custom block programmatically, like explained here : https://drupal.stackexchange.com/questions/183499/how-to-create-a-new-block-programmatically 因此,建议以编程方式创建自定义块,如此处所述: https : //drupal.stackexchange.com/questions/183499/how-to-create-a-new-block-programmaticly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM