如何将一个简单的jQuery滑块添加到Sharepoint 2010 Web部件 [英] How to I add a simple jquery slider to a Sharepoint 2010 web part

查看:115
本文介绍了如何将一个简单的jQuery滑块添加到Sharepoint 2010 Web部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过点击编辑HTML源代码将下面的代码添加到sharepoint web部件的html中。我正在使用来自网站的jquery插件。当我尝试将下面的代码提交到SharePoint Web部件的HTML中时,我收到消息:您输入的HTML源可能已被修改。结果,我看到的只有两条文本。我对sharepoint和jquery相当陌生。

 < script src =http是否使文本或图片幻灯片在共享点上的复杂程度比以下代码更复杂? ://code.jquery.com/jquery-latest.min.js>< /脚本> 
< script src =/ wg / PayrollSolutions / SiteAssets / unslider-min.js>< / script>

< script>
$(function(){
$('。banner')。unslider()
})
< / script>

< div class =banner>
< ul>
< li>滑块1< / li>
< li>滑块2< ; / li>
< / ul>
< / div>


SharePoint通常会清除所有直接添加到内容编辑器Web部件源代码中的JavaScript(尽管它将留在HTML和CSS中)。



不是直接将JavaScript添加到内容编辑器Web部件的源代码中,而是将其保存到文本文件中,然后将其上传到您网站的库中。



然后,在您的内容编辑器Web部件中,单击角落中的下拉菜单并选择编辑Web部件属性的选项。属性面板应显示在屏幕的侧面。



在Web部件属性的Content Link字段中,输入上传的文本文件的URL。内容编辑器Web部件将呈现该文本文件中的所有内容,包括HTML,CSS,a nd(最重要的)JavaScript。

这有附加好处,可以让您在多个页面上使用相同的HTML / JS片段。如果您需要进行更改,则可以更改该文件的内容,而无需再次编辑页面。


I am trying to add the following code to the html of a sharepoint web part by clicking on "Edit HTML Source". I am using a jquery plugin from the http://unslider.com/ website. When I try to submit the code below into the sharepoint web part's html, I get the message: "the HTML source you entered might have been modified". As a result, all I see are two bulletted lines of text. I'm fairly new to sharepoint and jquery. Is making text or picture slideshow a lot more complicated in sharepoint than the code below would suggest?

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/wg/PayrollSolutions/SiteAssets/unslider-min.js"></script>

<script>
    $(function() { 
        $('.banner').unslider() 
    })
</script>

<div class="banner">
    <ul>
        <li>Slider 1</li>
        <li>Slider 2</li>
    </ul>
</div>

解决方案

SharePoint will usually clean out any JavaScript added directly into the source of a content editor web part (although it'll leave in HTML and CSS).

Instead of adding the JavaScript directly into the source of a content editor web part, save it into a text file and upload it to a library on your site.

Then, in your content editor web part, click the drop-down in the corner and choose the option to edit the web part properties. The properties panel should appear on the side of the screen.

In the "Content Link" field in the web part properties, enter the URL of your uploaded text file. The content editor web part will then render whatever's in that text file, including HTML, CSS, and (most importantly) JavaScript.

This has the added benefit of allowing you to use the same snippet of HTML/JS on multiple pages. If you need to make changes, you can change the contents of that file without having to edit the page(s) again.

这篇关于如何将一个简单的jQuery滑块添加到Sharepoint 2010 Web部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆