bz3x bz3x - 7 months ago 111
Javascript Question

dynamically set endpoint in fine-uploader

I would like to set the request endpoint of fine-uploader dynamically.
For example:

$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: submitUrl
},
multiple: false,
button: $("#uploader-button"),
// etc...
});


submitUrl must be already set in the page and can't be changed.
I would like to do something more dynamic, something like:

request: {
endpoint: function() { ($('#submitUrlField').val() }
}


But the above sends the request to
function%20()%20%7B%20$(%27#submitUrlField%27).val()%20}

Grateful for anyone who knows how to do this!

Answer

your old code:

 request: {
        endpoint: function() { ($('#submitUrlField').val() }
      }
                               |_ why need ( becasue it has not close ) match

try one of these

request: {
   endpoint: function() { return $('#submitUrlField').val() }  // here you had `(`
}

or

request: {
   endpoint: $('#submitUrlField').val() 
}