在Sharepoint中添加可折叠标题(jQuery)
问题描述:
我在使用Sharepoint中的jQuery添加可折叠标题时遇到问题。我使用Sharepoint中的脚本编辑器Web部件导入jQuery,但是当我使用多个标记时,这会导致问题。在Sharepoint中添加可折叠标题(jQuery)
我的代码是:
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
我周围我的头用是
<div data-role="collapsible">
<h1>Header</h1>
<p>Content</p>
</div>
当我在脚本编辑器中添加脚本标签jQuery的代码,我的网页编辑按钮不再作品。我需要删除页面中的脚本部分,以便它再次运行。 我如何在Sharepoint中实现这一点?谢谢。
答
您提供的代码应该可以工作,但是如果您想尝试其他方法,则可以运行此代码。这将增加scriptlink到网页在您的网页位于(jQuery将在所有网页出现在这个特定的web)
JavaScript代码:
var clientContext = SP.ClientContext.get_current()
var web = clientContext.get_web();
var UserCustomActions = web.get_userCustomActions();
clientContext.load(UserCustomActions)
var action = UserCustomActions.add();
action.set_location('ScriptLink');
action.set_sequence(5);
action.set_title('jQuery');
action.set_description('jQuery');
action.set_scriptBlock("document.write(\"<script type='text/javascript' src='https://code.jquery.com/jquery-1.11.3.min.js'><\\/script>\");");
action.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args) {
alert("done");
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}