Jump to content
  • 0

Create Date-Specific New Record Links in Calendar DataPages whit wordpress deploy plugin


peterhanse

Question

Hi

Is there a way to make a  "Create Date-Specific New Record Links in Calendar DataPages" if we use the wordpress deploy methode.

I tried this code below but it only works in the preview.

<script>
var month = "";
var allSpanTags = document.getElementsByTagName("span");
for (i=0; i<allSpanTags.length; i++) {
if (allSpanTags[i].className == "cbResultSetCalendarCaption"){
month = allSpanTags[i].innerHTML;
}
}
month = month.replace(/January /gi,"1/Day/");
month = month.replace(/February /gi,"2/Day/");
month = month.replace(/March /gi,"3/Day/");
month = month.replace(/April /gi,"4/Day/");
month = month.replace(/May /gi,"5/Day/");
month = month.replace(/June /gi,"6/Day/");
month = month.replace(/July /gi,"7/Day/");
month = month.replace(/augustus /gi,"8/Day/");
month = month.replace(/September /gi,"9/Day/");
month = month.replace(/October /gi,"10/Day/");
month = month.replace(/November /gi,"11/Day/");
month = month.replace(/December /gi,"12/Day/");
var allHTMLTags = new Array();

//Create Array of All HTML Tags
var allHTMLTags = document.getElementsByTagName("div");

//Loop through all tags using a for loop
for (i=0; i<allHTMLTags.length; i++) {

//Get all tags with the specified class name.
if (allHTMLTags[i].className == "cbResultSetCalendarField") {
var transfer = month.replace(/Day/gi,allHTMLTags[i].innerHTML);

/*Begin Add New Link Section*/
allHTMLTags[i].innerHTML = allHTMLTags[i].innerHTML +'<br><a style="text-decoration:none;" href="https://horseplanner.nl/app/apl140/?datum='+transfer+'">Add New</a>';

/*End of Add New Link Section*/
}
}

</script>

 
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The className selectors are nice and clean in URL and Preview deployment. But when you use JS embed deployment on Report Datapages, unique IDs are appended to every class name on every page load. This has something to do with each record being a separate AJAX request, and inserting the response into the unique element. So I think if you inspect the page, you'll see that cbResultSetCalendarCaption becomes cbResultSetCalendarCaption_923746289379.

So a different selector method is needed. In tabular datapage reports, the strategy everywhere on this forum is to use DOM node traversal by first creating a unique DIV for each record by inserting an HTML block field, with a <div id="@field:uniqueID"></div>. Now you have a starting point (document.getElementById("@field:uniqueID")), to traverse up (parentNode), down (childNode) etc. from.

An alternative that can work in some cases is document.querySelectorAll, because it accepts wildcards, like contains,begins with, e.g. "CalendarCaption".

link: http://stackoverflow.com/questions/8714090/queryselector-wildcard-element-match

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...