Вопрос

I'm having issues using the content editor web part on publishing pages of a SharePoint 2010 site. I paste the following JavaScript into a CEWP:

<script>
$(document).ready(function () {
        /* Show the column headers for the views of
           the list named in the tables' summary attributes.
        */
  $("table[summary*='Move list']").each(function(){ 
    $(this).find("tr:eq(0)").show(); 
  }); 

  });
</script>

And it mangles it to this:

<script>
$(document).ready(function () {
        /* Show the column headers for the views of
           the list named in the tables' summary attributes.
        */
  $("table[summary*='Move list']").each(function(){
    $(this).find("t(0)").show();
  });
});
</script>

Notice the .find() has been changed. This is one of the less dramatic mangling done by the CEWP; I've had it rip entire chunks out of the code block.

Anyone know what causes this? Very annoying, and this happens with style tags too.

Это было полезно?

Решение

From what i can gather, seems like the CEWP has undergone some "improvement" in its 2010 incarnation.

One of this "improvement" is that the web part now perform some sort of "screening" on the html source code that a developer may try to insert, often resulting in invalid code without (almost) no warning.

Don't know if you are affect by the same issue, but this other question dig some more in the issue, providing some alterative solution. As a reference you could:

  • Use the HTML Form web part as Ziga suggested in his comment - this should solve the issue because the code won't be post processed
  • Use the Content Link property of the Content Editor web part to link an external script file (see this blog, you basically define a text file in a document library and then link that file from the web part)

Is an option for you to adopt one of this "workaround"?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top