javascript - External resources not reaching inside of function scope -
i'm trying make inventory picker trading website, i'm having trouble calling external resources.
when calling external function, goes correctly, whenever try call external function inside of function in html, errors, saying
uncaught typeerror: $(...).imagepicker not function
this relevant code.
<script src="~/scripts/image-picker.js"></script> <script> var name = "homeguarddev"; var inventory = []; var selecteditems = []; $.ajax({ async: false, type: 'get', url: "/home/getinventory/?username=" + name + "&page=1", success: function (data) { var parsed = json.parse(data); (var = 0; < parsed.length; i++) { var text = parsed[i].name; inventory[i] = parsed[i]; if (parsed[i].serialnumber !== "---") { text = text + " [#" + parsed[i].serialnumber + " / " + parsed[i].serialnumbertotal + "]"; } $("#sendingitems").append('<option data-img-label="<small>' + text + '</small>" data-img-src="' + parsed[i].imagelink + '" value="' + + '">' + text + '</option>'); } } }); $("#sendingitems").imagepicker({ show_label: true }); function additem() { if (selecteditems.length < 4) { var obj = (inventory[$("#sendingitems").val()]); if (!containsobject(obj, selecteditems)) { $('#sendingitems option[value="' + ($("#sendingitems").val()) + '"]').remove(); selecteditems.push(obj); $("#sendingitems").imagepicker({ show_label: true }); } } } </script> <p><a><input type="button" id="additembutton" onclick="additem()" value="add item" /></a></p> <p><a><input type="button" id="sendtradebutton" onclick="sendtrade()" value="send trade" /></a></p>
the error occurs inside of function additem() when calling imagepicker, in main block calls , functions correctly. doing incorrectly?
Comments
Post a Comment