Sharepoint 2007 占位符问题

发布于 2024-08-10 01:49:03 字数 438 浏览 8 评论 0原文

我在 jQuery 中为一些额外的 javascript 创建了一个简单的占位符 - 问题是占位符位于某些脚本标记内,因此 Sharepoint 设计器无法识别。

该页面工作正常,所以直到现在它还没有困扰我,因为如果不解决问题,你就无法触摸设计视图的任何部分。

我的代码在主模板中看起来像这样:

<script type="text/javascript>
  $(document).ready(function(){ 
    <asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server" />
  });
</script>

有没有一种方法可以使其正确工作,以便 Sharepoint Designer 实际上能够识别占位符?

感谢您的帮助!

I've created a simple placeHolder for some extra javascript in jQuery - The issue is that the placeHolder is within some script tags and therefore isn't recognized by Sharepoint designer.

The page works correctly, so it hasn't bothered me until now, since you can't touch any part of the design view, without fixing the issue.

My code looks something like this in the master template:

<script type="text/javascript>
  $(document).ready(function(){ 
    <asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server" />
  });
</script>

Is there a way to make this work correctly, so that the placeholder is actually recognized by Sharepoint Designer?

Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒解孤独 2024-08-17 01:49:03

我了解到您正在尝试调用在 PlaceHolder 中定义的 JavaScript 函数。
但是您的代码将无法工作,因为 PlaceHolder 是服务器控件,并且将其作为其他标签的子元素推送将无法工作。脚本标签是客户端处理标签。所以我建议改变如下逻辑。

在母版页中,我将默认使用 JavaScript 来调用函数。

<script type="text/javascript>
  $(document).ready(function(){ 
       myOnLoadFunction();
  });
</script>

我将使用虚拟函数定义内容占位符

<asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ //do nothing }</script>
</asp:ContentPlaceHolder>

现在,您可以在您的内容页面中定义

<asp:Content ID="javascript" ContentPlaceHolderID="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ alert('Hello jQuery');   }</script>
</asp:Content>

I understood that you are trying to call a JavaScript function that is defined inside the PlaceHolder.
But your code wont work as the PlaceHolder is a Server Control and pushing it as a child element of the some other tag wont work. Script tag is a client processing tag. So What I would suggest is to change the logic as below.

In the master page I will have a JavaScript to call a function by default.

<script type="text/javascript>
  $(document).ready(function(){ 
       myOnLoadFunction();
  });
</script>

And I will define the content Place Holder with a dummy function

<asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ //do nothing }</script>
</asp:ContentPlaceHolder>

Now in your content page you can define

<asp:Content ID="javascript" ContentPlaceHolderID="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ alert('Hello jQuery');   }</script>
</asp:Content>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文