This is a javascript/sharepoint question. p.s new to programming and this is modifying the current code.
I currently have a custom webpart with a 'Add new item' button that links to a template when clicked on. The goal is to amend the url of the template to include the title of the page where the webpart came from. E.g. The page is 'Test Page', test page has the webpart with 'Add new item', when clicked on 'Add new item' it takes to template page. Original URL = testtesttest%test%test%20.aspx?blah= and to add an &'page title' New URL = testtesttest%20test%20test%20.aspx?blah=&testpage.
Hope that make sense.
Below is a chunk of javascript code that I've found believe to be prepopulating something, how would I amend this to amend the url too?
function populateList (element, template, data) {
if (!element) {
return;
}
var templateHtml = '';
try {
var summaryTemplate = _.template(template);
templateHtml = summaryTemplate ({ items: data });
} catch (e) {
templatedHtml = 'Template failed';
}
$(element).html(templateHtml);
}