[jQuery] Re: How to check is element droppable
yes I'm using jQuery droppable. I am trying to check if some element is droppable. Example: /// code: script type=text/javascript $(#first).droppable(); ... ... /script div id=first/div div id=second/div /// end code now I need to check both divs (first and second) and find out which is droppable. In this example: script must write: div 'first' is droppable, div 'second' is not droppable Understand now? On Sep 16, 2:49 pm, Richard D. Worth rdwo...@gmail.com wrote: It's not clear. Are you trying to use an element with a tag name of 'droppable'? Are you using jQuery UI Droppable? - Richard On Tue, Sep 15, 2009 at 2:36 PM, Boris Trivic trivu...@gmail.com wrote: if question isn't clear, I can explain better :) On Sep 15, 7:33 pm, Boris Trivic trivu...@gmail.com wrote: Hi. How I can check this? I have next part of code where I must check is element tag = droppable. Instead code after // pseudo: i must add some function that check if element is droppable. If true it must write some text in that element (For example: $(tag).text('bla bla') ) // code / function help(){ // array generated by PHP: ?=$correct? // random num. from upper array: var rand = Math.floor( Math.random() * cor.length ); // Set tag if(rand != 0){ var tag = '#p'+rand; } // here goes code that check if tag is droppable... /// pseudo: if(tag is droppable){ alert('is dropable'); }} CODE /
[jQuery] Re: How to check is element droppable
thanks a lot, that's answer. Best regards! On Sep 16, 7:29 pm, Richard D. Worth rdwo...@gmail.com wrote: var isDroppable = $(#first).is(.ui-droppable); // boolean or var droppables = $(div).filter(.ui-droppable); // collection Also note, there's a separate list for jQuery UI questions, should you have any more: http://groups.google.com/group/jquery-ui - Richard On Wed, Sep 16, 2009 at 1:15 PM, Boris Trivic trivu...@gmail.com wrote: yes I'm using jQuery droppable. I am trying to check if some element is droppable. Example: /// code: script type=text/javascript $(#first).droppable(); ... ... /script div id=first/div div id=second/div /// end code now I need to check both divs (first and second) and find out which is droppable. In this example: script must write: div 'first' is droppable, div 'second' is not droppable Understand now? On Sep 16, 2:49 pm, Richard D. Worth rdwo...@gmail.com wrote: It's not clear. Are you trying to use an element with a tag name of 'droppable'? Are you using jQuery UI Droppable? - Richard On Tue, Sep 15, 2009 at 2:36 PM, Boris Trivic trivu...@gmail.com wrote: if question isn't clear, I can explain better :) On Sep 15, 7:33 pm, Boris Trivic trivu...@gmail.com wrote: Hi. How I can check this? I have next part of code where I must check is element tag = droppable. Instead code after // pseudo: i must add some function that check if element is droppable. If true it must write some text in that element (For example: $(tag).text('bla bla') ) // code / function help(){ // array generated by PHP: ?=$correct? // random num. from upper array: var rand = Math.floor( Math.random() * cor.length ); // Set tag if(rand != 0){ var tag = '#p'+rand; } // here goes code that check if tag is droppable... /// pseudo: if(tag is droppable){ alert('is dropable'); }} CODE /
[jQuery] Re: droppable limit
Other solution is to add next code below ...drop: function(){... $(this).droppable('disable'); logicaly, it will disable drop on element... If you want enable drop, again, add next code below ...out: function (event, ui) {... $(this).droppable('disable'); Hope it helps... On Sep 8, 3:27 am, Richard D. Worth rdwo...@gmail.com wrote: The accept option can take a function. That function gets called when a draggable starts being dragged and the draggable item is sent as the first argument to the function. So if your droppable already has an item, simply return false in that function, otherwise return true. The other option would be to disable or destroy your droppable, once it has an item. - Richard On Sat, Sep 5, 2009 at 10:16 AM, pEeLL milan.h...@gmail.com wrote: Hi i use for drag and drop this easy code $(function() { $(.ui-draggable).draggable({ revert: 'invalid' }); $(.ui-droppable).droppable({ accept: '.ui-draggable', drop: function(event, ui) { $(this).addClass('red'); }, out: function(event, ui) { $(this).removeClass('red'); } }); }); i have some boxes and some containers. i want add ONLY one box to one container. How can i limit number of boxex that will container accept? thanks for every help.
[jQuery] How to check is element droppable
Hi. How I can check this? I have next part of code where I must check is element tag = droppable. Instead code after // pseudo: i must add some function that check if element is droppable. If true it must write some text in that element (For example: $(tag).text('bla bla') ) // code / function help(){ // array generated by PHP: ?=$correct? // random num. from upper array: var rand = Math.floor( Math.random() * cor.length ); // Set tag if(rand != 0){ var tag = '#p'+rand; } // here goes code that check if tag is droppable... /// pseudo: if(tag is droppable){ alert('is dropable'); } } CODE /
[jQuery] Re: How to check is element droppable
if question isn't clear, I can explain better :) On Sep 15, 7:33 pm, Boris Trivic trivu...@gmail.com wrote: Hi. How I can check this? I have next part of code where I must check is element tag = droppable. Instead code after // pseudo: i must add some function that check if element is droppable. If true it must write some text in that element (For example: $(tag).text('bla bla') ) // code / function help(){ // array generated by PHP: ?=$correct? // random num. from upper array: var rand = Math.floor( Math.random() * cor.length ); // Set tag if(rand != 0){ var tag = '#p'+rand; } // here goes code that check if tag is droppable... /// pseudo: if(tag is droppable){ alert('is dropable'); }} CODE /
[jQuery] Re: App like hangman
Problem fixed with: helper: clone in draggable element... On Aug 26, 8:19 pm, Boris Trivic trivu...@gmail.com wrote: Well, maybe you don't understand whats the problem, so here is screenshot: http://caraudio-rs.info/snapshot1.png Do you think it's the bug or my mistake? On Aug 25, 1:08 pm, Boris Trivic trivu...@gmail.com wrote: omg! I just opened it in Opera (Linux) and there is some kind of bug or what? Instead revert to original location, chars returns about 100-150px right... Can someone take a look and check if same problem occurs? Maybe I shoult report it to jQuery dev team? On Aug 25, 7:00 pm, Boris Trivic trivu...@gmail.com wrote: Yeah, sure, it imposible to convert object to string, object has methods and properties for that what I want. Wheathever, thanks a lot Brett one more time, you saved me. I finished a main part of project, there is still some little stufs to fix and correct. You can take a look on next link, if you want: http://caraudio-rs.info/nal_7/ On Aug 25, 12:17 am, Brett Ritter swift...@swiftone.org wrote: On Mon, Aug 24, 2009 at 11:24 AM, Boris Trivictrivu...@gmail.com wrote: I can success print ui.draggable to console, but how to convert it to string? I need to write it into some element with .innerHTML and I will probably use it in for loop... I think you are trying the hard way. ui.draggable is not a string, but a jQuery element. Use that as you see fit. For Hangman you're probably looking to copy either the text ( ui.draggable.text() ) or the html itself ( ui.draggable.html() ). If you need to clone the source you want ui.draggable.clone() (note that any events bound to the original are not bound to the clone unless you use live() ) Trying to convert a jQuery element to a string doesn't make sense unless you say what string you want - the text, the html, the id, these are all different strings. -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
Well, maybe you don't understand whats the problem, so here is screenshot: Do you think it's the bug or my mistake?
[jQuery] Re: App like hangman
http://caraudio-rs.info/snapshot1.png On Aug 26, 8:15 pm, Boris Trivic trivu...@gmail.com wrote: Well, maybe you don't understand whats the problem, so here is screenshot: Do you think it's the bug or my mistake?
[jQuery] Re: App like hangman
Well, maybe you don't understand whats the problem, so here is screenshot: http://caraudio-rs.info/snapshot1.png Do you think it's the bug or my mistake? On Aug 25, 1:08 pm, Boris Trivic trivu...@gmail.com wrote: omg! I just opened it in Opera (Linux) and there is some kind of bug or what? Instead revert to original location, chars returns about 100-150px right... Can someone take a look and check if same problem occurs? Maybe I shoult report it to jQuery dev team? On Aug 25, 7:00 pm, Boris Trivic trivu...@gmail.com wrote: Yeah, sure, it imposible to convert object to string, object has methods and properties for that what I want. Wheathever, thanks a lot Brett one more time, you saved me. I finished a main part of project, there is still some little stufs to fix and correct. You can take a look on next link, if you want: http://caraudio-rs.info/nal_7/ On Aug 25, 12:17 am, Brett Ritter swift...@swiftone.org wrote: On Mon, Aug 24, 2009 at 11:24 AM, Boris Trivictrivu...@gmail.com wrote: I can success print ui.draggable to console, but how to convert it to string? I need to write it into some element with .innerHTML and I will probably use it in for loop... I think you are trying the hard way. ui.draggable is not a string, but a jQuery element. Use that as you see fit. For Hangman you're probably looking to copy either the text ( ui.draggable.text() ) or the html itself ( ui.draggable.html() ). If you need to clone the source you want ui.draggable.clone() (note that any events bound to the original are not bound to the clone unless you use live() ) Trying to convert a jQuery element to a string doesn't make sense unless you say what string you want - the text, the html, the id, these are all different strings. -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
Yeah, sure, it imposible to convert object to string, object has methods and properties for that what I want. Wheathever, thanks a lot Brett one more time, you saved me. I finished a main part of project, there is still some little stufs to fix and correct. You can take a look on next link, if you want: http://caraudio-rs.info/nal_7/ On Aug 25, 12:17 am, Brett Ritter swift...@swiftone.org wrote: On Mon, Aug 24, 2009 at 11:24 AM, Boris Trivictrivu...@gmail.com wrote: I can success print ui.draggable to console, but how to convert it to string? I need to write it into some element with .innerHTML and I will probably use it in for loop... I think you are trying the hard way. ui.draggable is not a string, but a jQuery element. Use that as you see fit. For Hangman you're probably looking to copy either the text ( ui.draggable.text() ) or the html itself ( ui.draggable.html() ). If you need to clone the source you want ui.draggable.clone() (note that any events bound to the original are not bound to the clone unless you use live() ) Trying to convert a jQuery element to a string doesn't make sense unless you say what string you want - the text, the html, the id, these are all different strings. -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
omg! I just opened it in Opera (Linux) and there is some kind of bug or what? Instead revert to original location, chars returns about 100-150px right... Can someone take a look and check if same problem occurs? Maybe I shoult report it to jQuery dev team? On Aug 25, 7:00 pm, Boris Trivic trivu...@gmail.com wrote: Yeah, sure, it imposible to convert object to string, object has methods and properties for that what I want. Wheathever, thanks a lot Brett one more time, you saved me. I finished a main part of project, there is still some little stufs to fix and correct. You can take a look on next link, if you want: http://caraudio-rs.info/nal_7/ On Aug 25, 12:17 am, Brett Ritter swift...@swiftone.org wrote: On Mon, Aug 24, 2009 at 11:24 AM, Boris Trivictrivu...@gmail.com wrote: I can success print ui.draggable to console, but how to convert it to string? I need to write it into some element with .innerHTML and I will probably use it in for loop... I think you are trying the hard way. ui.draggable is not a string, but a jQuery element. Use that as you see fit. For Hangman you're probably looking to copy either the text ( ui.draggable.text() ) or the html itself ( ui.draggable.html() ). If you need to clone the source you want ui.draggable.clone() (note that any events bound to the original are not bound to the clone unless you use live() ) Trying to convert a jQuery element to a string doesn't make sense unless you say what string you want - the text, the html, the id, these are all different strings. -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
OK, again I need some help: I can success print ui.draggable to console, but how to convert it to string? I need to write it into some element with .innerHTML and I will probably use it in for loop... Any your comment will be helpfull. On Aug 24, 2:45 am, Boris Trivic trivu...@gmail.com wrote: Brett thanks for your help, I success founded solution deeper on link that you posted. If someone needs, here is code: $(.place).droppable({ drop: function(e, ui) { console.log(ui.droppable); } }); This code writes in console (if you use Firebug), which element is dragged (id of that el.). You can customize code for your needs... On Aug 20, 4:30 am, Brett Ritter swift...@swiftone.org wrote: On Wed, Aug 19, 2009 at 11:07 AM, Boris Trivictrivu...@gmail.com wrote: When I take on of draggable divs and put it on 3rd div (fixed), how I can get ID of that div which is dragged on 3rd div. Ah! Now I understand. (Good examples). Sadly, Drag-and-drop is not something I've played with. However, from looking at the jqueryUI docs, it appears what you are looking for is the Droppable plugin, which receives draggable objects: http://jqueryui.com/demos/droppable/ Hope that helps! -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
Brett thanks for your help, I success founded solution deeper on link that you posted. If someone needs, here is code: $(.place).droppable({ drop: function(e, ui) { console.log(ui.droppable); } }); This code writes in console (if you use Firebug), which element is dragged (id of that el.). You can customize code for your needs... On Aug 20, 4:30 am, Brett Ritter swift...@swiftone.org wrote: On Wed, Aug 19, 2009 at 11:07 AM, Boris Trivictrivu...@gmail.com wrote: When I take on of draggable divs and put it on 3rd div (fixed), how I can get ID of that div which is dragged on 3rd div. Ah! Now I understand. (Good examples). Sadly, Drag-and-drop is not something I've played with. However, from looking at the jqueryUI docs, it appears what you are looking for is the Droppable plugin, which receives draggable objects: http://jqueryui.com/demos/droppable/ Hope that helps! -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
anyone? :s On Aug 19, 12:20 am, Boris Trivic trivu...@gmail.com wrote: I think you didn't understand my question. I need to check is right char (it is in div) putted on right line (lines are divs, too). On Aug 18, 11:38 pm, anurag pal mail.anurag@gmail.com wrote: Hi, You can use float for this purpose Like: div style=width:100%;float:left;a/div div style=width:50%;float:left;b/divdiv style=width:50%;float:left;c/div you can use attr method for getting this. Regards, Anurag Pal On Tue, Aug 18, 2009 at 7:07 PM, Boris Trivic trivu...@gmail.com wrote: OK thanks for reply. Which function enables me to find out which div is puted on which? Exaple: div1 div2 div3 when I pul div 2 on div3, how i can find out which element is puted on div3 (div1 or div2)? On Aug 18, 2:18 pm, anurag pal mail.anurag@gmail.com wrote: Hi, You can acheive this with Jquery. Regards, Anurag Pal On Tue, Aug 18, 2009 at 12:55 AM, Boris Trivic trivu...@gmail.com wrote: Hi everyone. I need to create one project (some kind of game) and I want to know, is that possible create with jQuery? Page should looks like this: _---_---_---_---_ --- A B C D E F G H I J K L M N O P R S T U V Z X Y Z -- word lines - __ __ __ __ __ _---_---_---_---_---_- In upper part, there is alphabet and from it I have to pull chars on lines in down part. Behaviors of application: 1 If char is not on correct place it shoul be different color. 2 when I pull one char from upper table and drop it on line, it shouldn't disapear from list of chars 3 there must be possibility to pull out char from word lines 4 when user moves char (ex: 20px) it should disapear from lines I'm planing to put chars in div and maybe it will be image, but that's not matter. I founded good documentation (draggable and dropable)and I was reading for few minutes, and I thing it should be possible. Is there any function, option or something that checks which element is draged on which? If someone has some good idea, link or some other kind of help, I'll be thankfull for anything. Thank you
[jQuery] Re: App like hangman
look. Exaple: i have 3 div's with different ID's. First 2 divs are draggable, 3rd is fixed. When I take on of draggable divs and put it on 3rd div (fixed), how I can get ID of that div which is dragged on 3rd div. --code: script type=text/javascript $(#div1).draggable(); $(#div2).draggable(); /script body div id=div1 A /div div id=div2 B /div div id=div3 __ /div .. -end code-- If you read my 1st post you can see what I want to make... You understand now? On Aug 19, 10:13 pm, Brett Ritter swift...@swiftone.org wrote: On Wed, Aug 19, 2009 at 9:40 AM, Boris Trivictrivu...@gmail.com wrote: anyone? :s I'm afraid I'm not understanding your question. Can you provide simple html that you are trying to read/manipulate? -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
here is live page, but just begin http://caraudio-rs.info/nal_7/ On Aug 19, 11:07 pm, Boris Trivic trivu...@gmail.com wrote: look. Exaple: i have 3 div's with different ID's. First 2 divs are draggable, 3rd is fixed. When I take on of draggable divs and put it on 3rd div (fixed), how I can get ID of that div which is dragged on 3rd div. --code: script type=text/javascript $(#div1).draggable(); $(#div2).draggable(); /script body div id=div1 A /div div id=div2 B /div div id=div3 __ /div .. -end code-- If you read my 1st post you can see what I want to make... You understand now? On Aug 19, 10:13 pm, Brett Ritter swift...@swiftone.org wrote: On Wed, Aug 19, 2009 at 9:40 AM, Boris Trivictrivu...@gmail.com wrote: anyone? :s I'm afraid I'm not understanding your question. Can you provide simple html that you are trying to read/manipulate? -- Brett Ritter / SwiftOne swift...@swiftone.org
[jQuery] Re: App like hangman
OK thanks for reply. Which function enables me to find out which div is puted on which? Exaple: div1 div2 div3 when I pul div 2 on div3, how i can find out which element is puted on div3 (div1 or div2)? On Aug 18, 2:18 pm, anurag pal mail.anurag@gmail.com wrote: Hi, You can acheive this with Jquery. Regards, Anurag Pal On Tue, Aug 18, 2009 at 12:55 AM, Boris Trivic trivu...@gmail.com wrote: Hi everyone. I need to create one project (some kind of game) and I want to know, is that possible create with jQuery? Page should looks like this: _---_---_---_---_ --- A B C D E F G H I J K L M N O P R S T U V Z X Y Z -- word lines - __ __ __ __ __ _---_---_---_---_---_- In upper part, there is alphabet and from it I have to pull chars on lines in down part. Behaviors of application: 1 If char is not on correct place it shoul be different color. 2 when I pull one char from upper table and drop it on line, it shouldn't disapear from list of chars 3 there must be possibility to pull out char from word lines 4 when user moves char (ex: 20px) it should disapear from lines I'm planing to put chars in div and maybe it will be image, but that's not matter. I founded good documentation (draggable and dropable)and I was reading for few minutes, and I thing it should be possible. Is there any function, option or something that checks which element is draged on which? If someone has some good idea, link or some other kind of help, I'll be thankfull for anything. Thank you
[jQuery] Re: App like hangman
I think you didn't understand my question. I need to check is right char (it is in div) putted on right line (lines are divs, too). On Aug 18, 11:38 pm, anurag pal mail.anurag@gmail.com wrote: Hi, You can use float for this purpose Like: div style=width:100%;float:left;a/div div style=width:50%;float:left;b/divdiv style=width:50%;float:left;c/div you can use attr method for getting this. Regards, Anurag Pal On Tue, Aug 18, 2009 at 7:07 PM, Boris Trivic trivu...@gmail.com wrote: OK thanks for reply. Which function enables me to find out which div is puted on which? Exaple: div1 div2 div3 when I pul div 2 on div3, how i can find out which element is puted on div3 (div1 or div2)? On Aug 18, 2:18 pm, anurag pal mail.anurag@gmail.com wrote: Hi, You can acheive this with Jquery. Regards, Anurag Pal On Tue, Aug 18, 2009 at 12:55 AM, Boris Trivic trivu...@gmail.com wrote: Hi everyone. I need to create one project (some kind of game) and I want to know, is that possible create with jQuery? Page should looks like this: _---_---_---_---_ --- A B C D E F G H I J K L M N O P R S T U V Z X Y Z -- word lines - __ __ __ __ __ _---_---_---_---_---_- In upper part, there is alphabet and from it I have to pull chars on lines in down part. Behaviors of application: 1 If char is not on correct place it shoul be different color. 2 when I pull one char from upper table and drop it on line, it shouldn't disapear from list of chars 3 there must be possibility to pull out char from word lines 4 when user moves char (ex: 20px) it should disapear from lines I'm planing to put chars in div and maybe it will be image, but that's not matter. I founded good documentation (draggable and dropable)and I was reading for few minutes, and I thing it should be possible. Is there any function, option or something that checks which element is draged on which? If someone has some good idea, link or some other kind of help, I'll be thankfull for anything. Thank you
[jQuery] App like hangman
Hi everyone. I need to create one project (some kind of game) and I want to know, is that possible create with jQuery? Page should looks like this: _---_---_---_---_ --- A B C D E F G H I J K L M N O P R S T U V Z X Y Z -- word lines - __ __ __ __ __ _---_---_---_---_---_- In upper part, there is alphabet and from it I have to pull chars on lines in down part. Behaviors of application: 1 If char is not on correct place it shoul be different color. 2 when I pull one char from upper table and drop it on line, it shouldn't disapear from list of chars 3 there must be possibility to pull out char from word lines 4 when user moves char (ex: 20px) it should disapear from lines I'm planing to put chars in div and maybe it will be image, but that's not matter. I founded good documentation (draggable and dropable)and I was reading for few minutes, and I thing it should be possible. Is there any function, option or something that checks which element is draged on which? If someone has some good idea, link or some other kind of help, I'll be thankfull for anything. Thank you