ブログサイトの投稿のためのPOSTのCSRの変更/変更
-
10-12-2019 - |
質問
私はCSRに取り組んでボタンを追加して、ブログサイトのようなルックアンドフィールを変更し、コメントボタンを変更します。現在私はこれを達成することができ、機能的(ボタン)です。
下記(JSLink)コードを使用してそれを実現しています。
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = { 'Body':{'View': CBody} };
console.log("Registering CSR");
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function CBody(ctx) {
var ret = ctx.CurrentItem.Body + "<b>" +
"<button onclick='myfunc(ctx);' type='button' >Report Abuse</button>" + "</b><hr/>" ;
return ret;
}
.
今、私はそれがこのように見えるべきです。
画像1のコメントボタンの後にボタンを追加できるような方法は、その後、CSSの操作が容易になると
私は以下のように上書きしようとしました、
overrideCtx.Templates.Fields = { 'PostCategory':{'View': CDate} };
function CDate(ctx) {
var ret = "<br> <b>" +
"<button onclick='func(ctx);' type='button' >One More Test</button>" + "</b><hr/>" ;
return ret;
}
.
しかし私の運のためにそれはまったくうまくいきませんでした。 どのような分野で私の訴訟を上書きするべきですか。CSRはSharePoint用に文書化されていますか?
解決
The command bar/links such as Like, Comment etc are outside the Body section of the blog. You can see the rendered HTML in firebug/IE developer tools.
Instead of overring the Body field, create a PostRenderHandler for your view and then it's all about injecting your extra HTML mark up at the correct element.
overrideContext.OnPostRender = your_function_here();
Within your postRender function, add something like this:
var ulDD = $("ul.ms-comm-forumCmdList li:last-child");
ulDD.before("<li id='liButton1' class='ms-comm-cmdSpaceListItem'><span><a class='myBtn' href='#'>Share</a></span></li><li id='liButton2' class='ms-comm-cmdSpaceListItem'><span><a class='myBtn' href='#'>Report</a></span></li>");
that would result as:
所属していません sharepoint.stackexchange