I’m using Andrew Valums’ Ajax Upload plugin (GitHub link). Here is some code from it:
qq.getUniqueId = (function(){
var id = 0;
return function(){ return id++; };
})();
It’s kind of a long story, but I’m in a situation where, under certain circumstances, I’d like the qq.getUniqueId function to start with an ID other than 0. It can still increment by one; it just has to start with something other than 0. What’s the best way to do that?
Here are the steps to create a test environment:
-
Download the plugin: http://github.com/valums/file-uploader/zipball/master
-
Unzip it and move the “client” folder onto a web server.
-
Open the “demo.htm” file in a text editor, search for
action: 'do-nothing.htm',and addonComplete: function(id, fileName, responseJSON) {alert(id)},right after that. -
Open the “demo.htm” file in a web browser. Be sure to access it through a web server (as opposed to just opening the local file) or else it won’t work.
-
Upload a file. It should alert a “0” after the upload finishes. See if you can modify it so that I can pass in a different starting number.
Thanks!
Try replacing the function with one that calls the original, but adds an offset:
See http://jsfiddle.net/alnitak/gWjqX/