Reputation: 307
I have a html file that has following code,
<div id="pp-photo-wrap">
<input id="fileupload" type="file" name="files[]">
//Added this to debug
<input id="debug" type="button" value="Print Design" onclick="alert(globalVars.selectedDesignId)" />
<script>
$j(document).ready(function(){
$j('#fileupload').fileupload({
dataType: 'json',
url: 'productpage/uploadphoto?design='+ globalVars.selectedDesignId,
done: function (e, data) {
enablephotostudio(data);
}
});
});
</script>
</div>
and I have another JS file with the following function that does heaps of stuff and among those it does the following,
function clickDesignItem(item_el) {
...
...
globalVars.selectedDesignId = item_el.data('design_id');
...
...
}
So my problem is I want to pass current globalVars.selectedDesignId
in to fileupload()
function along with the URL. but it always give me the design ID which the one it had when the document is loading.
But if I click on the "Print Design" button which I added to see weather globalVars.selectedDesignId
has the correct value at the time fileupload()
is calling, give me the current correct design ID.
So how do I reload the document.ready
or pass the globalVars.selectedDesignId
with the updated value?
Need help badly...
Upvotes: 0
Views: 100
Reputation: 36531
Basically users will select a design,
so that means (i am guessing) clickDesignItem
.. function is called first, where globalVars
is defined , calling fileupload function after that will get the globalVars
as it should...
but here, you are calling the fileupload
inside document.ready()
.that means fileupload is called as soon as the document gets ready thus your globalVars
might not be set till then....
Upvotes: 1