I'm trying to connect Ribbon to Pages.. This works, javascript get what I need and pass as parameter to my page.. I pass the URL and the SelectedItemsID..
I'm facing a problem:
If I had a List caller (for example) "List - 1" in URL I find "List%20%201" so there is no trace of the "-"
The response I gave to me is to pass the list name from Javascript as a parameter... How can I get this parameter? My custom action code is this:
function enable() {
var items = SP.ListOperation.Selection.getSelectedItems();
var itemCount = CountDictionary(items);
return (itemCount > 0);
}
function CallMe() {
var context = SP.ClientContext.get_current();
this.site = context.get_site();
this.web = context.get_web();
context.load(this.site);
context.load(this.web);
context.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
var items = SP.ListOperation.Selection.getSelectedItems();
var itemCount = CountDictionary(items);
if (itemCount == 0) return;
var ids = "";
for (var i = 0; i < itemCount; i++) {
ids += items[i].id + ";";
}
//send a request to the zip aspx page.
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", this.web.get_serverRelativeUrl() + "/_layouts/deviantpoint.downloadzip/downloadzip.aspx");
var hfSourceUrl = document.createElement("input");
hfSourceUrl.setAttribute("type", "hidden");
hfSourceUrl.setAttribute("name", "sourceUrl");
hfSourceUrl.setAttribute("value", location.href);
form.appendChild(hfSourceUrl);
var hfItemIds = document.createElement("input")
hfItemIds.setAttribute("type", "hidden");
hfItemIds.setAttribute("name", "itemIDs");
hfItemIds.setAttribute("value", ids);
form.appendChild(hfItemIds);
document.body.appendChild(form);
form.submit();
}
function onQueryFailed(sender, args) {
this.statusID = SP.UI.Status.addStatus("Download as Zip:",
"Failed: " + args.get_message() + " <a href='#' onclick='javascript:closeStatus();return false;'>Close</a>.", true);
SP.UI.Status.setStatusPriColor(this.statusID, "red");
}
function closeStatus() {
SP.UI.Status.removeStatus(this.statusID);
}