Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Move this topic
Forum :
Getting Started
Using jQuery
Using jQuery Plugins
Using jQuery UI
Developing jQuery Core
Developing jQuery Plugins
Developing jQuery UI
QUnit and Testing
About the jQuery Forum
jQuery Conferences
jQuery Mobile
Developing jQuery Mobile
Sub forum :
Move this topic
Cancel
Getting Started
vatanay
jQuery drag and drop inventory (database interaction)
in
Getting Started
•
4 months ago
Im working on jquery drag and drop inv scripts for my web based game but i need help about item limitation.
I want to limit number of items in inventory.How can i do this?
im using these files atm :
http://dannyvankooten.com/231/create-drag-and-drop-inventory-using-jquery/
http://dannyvankooten.com/259/jquery-drag-and-drop-inventory-database-interaction-22
Thanks!
1
Reply
Replies(5)
charlietfl
Re: jQuery drag and drop inventory (database interaction)
4 months ago
you can pass in option 'disabled' after you count your items
in docs look on options tab
Leave a comment on charlietfl's reply
vatanay
Re: jQuery drag and drop inventory (database interaction)
4 months ago
thanks but how?
I have no experience about editing js files.
Cant you help?
These are my codes;
<script type="text/javascript">
function itemInSpot(drag_item,spot)
{
var oldSpotItem = $(spot).find('img');
if(oldSpotItem.length > 0) {
oldSpotItem.appendTo('#inventory').draggable({ revert: 'invalid' });
}
var item = $('<img />');
drag_item.empty().remove(); // remove the old object
item.attr('src',drag_item.attr('src')).attr('id',drag_item.attr('id')).attr('class',drag_item.attr('class')).appendTo(spot).draggable({ revert: 'invalid' });
update_spots(); // update the DB
}
function update_spots()
{
// Create a list of all the items
var inventory_items = '';
var helm_item = ($('#helm img').length > 0) ? $('#helm img').attr('id') : '';
var shield_item = ($('#shield img').length > 0) ? $('#shield img').attr('id') : '';
var armor_item = ($('#armor img').length > 0) ? $('#armor img').attr('id') : '';
var axe_item = ($('#axe img').length > 0) ? $('#axe img').attr('id') : '';
var sword_item = ($('#sword img').length > 0) ? $('#sword img').attr('id') : '';
var bow_item = ($('#bow img').length > 0) ? $('#bow img').attr('id') : '';
var leggings_item = ($('#leggings img').length > 0) ? $('#leggings img').attr('id') : '';
$('#inventory img').each(
function(i) {
if($(this).attr('id') != '') {
if(inventory_items.length > 1) inventory_items += ',';
inventory_items += $(this).attr('id');
}
}
);
var uri = 'update_inventory.php?helm='+helm_item+'&armor='+armor_item+'&leggings='+leggings_item+'&shield='+shield_item+'&bow='+bow_item+'&axe='+axe_item+'&sword='+sword_item+'&inventory='+inventory_items;
$.ajax({ url: uri });
}
$(document).ready(function() {
$(".sword,.helm,.axe,.armor,.shield,.bow,.leggings").draggable({ revert: 'invalid'});
$('#inventory').droppable();
$("#sword").droppable({ accept: '.sword'})
$("#helm").droppable({ accept: '.helm'})
$("#leggings").droppable({ accept: '.leggings'})
$("#axe").droppable({ accept: '.axe'})
$('#shield').droppable({ accept: '.shield'});
$('#armor').droppable({ accept: '.armor'});
$('#bow').droppable({ accept: '.bow'});
$('#sword,#helm,#axe,#shield,#armor,#bow,#leggings,#inventory').bind('drop', function(ev,ui) { itemInSpot(ui.draggable,this); });
});
</script>
Leave a comment on vatanay's reply
vatanay
Re: jQuery drag and drop inventory (database interaction)
4 months ago
I still need help
Leave a comment on vatanay's reply
vatanay
Re: jQuery drag and drop inventory (database interaction)
3 months ago
up!
Leave a comment on vatanay's reply
charlietfl
Re: jQuery drag and drop inventory (database interaction)
3 months ago
within your "drop" handler you can run a test for whatever conditions you need....we have no idea what those are
to disable a droppable:
$(selector).droppable('option','disabled', true) // false should re-enable
Leave a comment on charlietfl's reply
Change topic type
Topic Type :
Discussions
Questions
Ideas
Problems
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to vatanay's question
Top
Reply
{"z8258732":[14737000002958578,14737000002958683,14737000002963541,14737000003053871],"z1411412":[14737000002960017,14737000003059151]}
Statistics
5
Replies
542
Views
0
Followers
Tags
No tags available for this topic.
Cancel
Actions
Permalink
Related Posts
Can’t figure out how to capture PHP...
Jquery change my text to utf-8 when...
jQuery UI Multiselect not showing u...
How to open accordion from external...
jQuery + Adobe AIR