Can you disable the mobile upload widget?

Can you disable the mobile upload widget?

  

Mobile widgets such as input, switch, and button have an enabled property, but the upload widget does not.  How can I show it but not allow the user to make changes?

Solution

Is this something you want to do AFTER you've used the Upload Widget?  E.g. Upload then disable?

Using the Enabled property in a Widget (like Input) adds the attribute "disabled" (no quotes) to that tag.

For those Widgets that do not have the Enabled property you can use Javascript to add the disabled attribute.

For example, if the Name of your Upload Widget is Upload1, then you can use this code in a Javascript module...

var uplObj = document.getElementById("Upload1");
var fileTag = uplObj.childNodes[0];
fileTag.setAttribute("disabled","disabled");

This code gets the Upload1 Object, then gets its first Child Node... which is the <input type=file tag we need.

Now that we have the right tag, the disabled attribute is added.  No more uploading.

Solution

Thanks David for pointing the right direction.  Since I have multiple upload widgets to disable at once, I used these JavaScripts:

Disable all:

var xs = document.getElementsByClassName("upload");
for (var i = 0; i < xs.length; i++) {
xs[i].childNodes[0].setAttribute("disabled","disabled");
xs[i].childNodes[2].style.visibility = "hidden";}


Enable all:

var xs = document.getElementsByClassName("upload");
for (var i = 0; i < xs.length; i++) {
xs[i].childNodes[0].removeAttribute("disabled","disabled");
xs[i].childNodes[2].style.visibility = "visible";}

I also hide the banner across the widget that says "change" since you can't change the file anyway.

Very nice.

I wish OS Web would offer the same ease of using Javascript.