[jQuery] Dragable Limit
Is there a way to limit the number of divs that can be placed inside my droppable div? I haven't found it on the docs. I'm sure its simple, I just cannot find an answer. Thanks!
[jQuery] Re: jQuery and Javascript timer question
Right but you can have to classes defined to one element, and thats what is being done here. The statement does validate nonetheless, but rather why this.css doesn't correctly reassign the background is what i"m unsure of. On Feb 1, 12:20 pm, brian wrote: > On Sun, Feb 1, 2009 at 12:09 PM, thertze...@gmail.com > > wrote: > > > what? > > > That statement checks to see if the element clicked has the class > > of .btn px, I dont know what your saying, the statement there does > > work correctly, its "\$(this).css({ backgroundColor:color }); " that > > isnt modifying the css, thats where my problems are. > > Class names cannot have spaces. Ricardo is correct; the selector > you're using is for a "px" element inside of another with classname > 'btn'. > > > It's being ran from perl, so when perl is parsing the print statement, > > it thinks $~whatever is a perl variable. Which is strange, because > > normally use strict; will bark at you, but instead perl finds a way to > > find out what $~whatever is. Its kinda strange, so I have to escape > > them server side, but client side they come out as normal $ > > Sure it requires escaping for Perl. But, effectively, you're posting a > Perl print statement, not JS. Post the actual, real lines of code, as > it will be when it meets the interpreter. Any format it's in before it > reaches the browser is unimportant and just getting in the way. Just > "view source" and copy that. > > Next, people will be posting their gzipped scripts to be debugged. ;-)
[jQuery] Re: jQuery and Javascript timer question
what? That statement checks to see if the element clicked has the class of .btn px, I dont know what your saying, the statement there does work correctly, its "\$(this).css({ backgroundColor:color }); " that isnt modifying the css, thats where my problems are. On Feb 1, 9:29 am, Ricardo Tomasi wrote: > are you putting that code inside $(document).ready? > > if ( \$(e.target).is('.btn px') ) is checking if the clicked element > is a element inside .btn, that condition will never be > satisfied, will it? > > On Feb 1, 12:38 pm, "thertze...@gmail.com" > wrote: > > > It's being ran from perl, so when perl is parsing the print statement, > > it thinks $~whatever is a perl variable. Which is strange, because > > normally use strict; will bark at you, but instead perl finds a way to > > find out what $~whatever is. Its kinda strange, so I have to escape > > them server side, but client side they come out as normal $ > > > On Jan 31, 10:54 pm, brian wrote: > > > > On Sat, Jan 31, 2009 at 11:19 PM, thertze...@gmail.com > > > > wrote: > > > > > \$(this).css({ backgroundColor:color }); never seem to fire, as far as > > > > I know though, its valid jquery javascript... > > > > > As for the statement above "("input#color_code").val() " is whatever > > > > the user selects from the color picker. > > > > > If anyone is questioning my \$ in my javascript, i have to do it this > > > > way, because I'm running this with a Perl script, and perl uses $ to > > > > define and use variables. > > > > Using the backslash within a Perl script which writes your javascript, > > > I can well understand. But the output--what the JS interpreter > > > sees--should be a bare $, not \$. > > > > In any case, why not just use jQuery.noConflict()?
[jQuery] Re: jQuery and Javascript timer question
It's being ran from perl, so when perl is parsing the print statement, it thinks $~whatever is a perl variable. Which is strange, because normally use strict; will bark at you, but instead perl finds a way to find out what $~whatever is. Its kinda strange, so I have to escape them server side, but client side they come out as normal $ On Jan 31, 10:54 pm, brian wrote: > On Sat, Jan 31, 2009 at 11:19 PM, thertze...@gmail.com > > wrote: > > > \$(this).css({ backgroundColor:color }); never seem to fire, as far as > > I know though, its valid jquery javascript... > > > As for the statement above "("input#color_code").val() " is whatever > > the user selects from the color picker. > > > If anyone is questioning my \$ in my javascript, i have to do it this > > way, because I'm running this with a Perl script, and perl uses $ to > > define and use variables. > > Using the backslash within a Perl script which writes your javascript, > I can well understand. But the output--what the JS interpreter > sees--should be a bare $, not \$. > > In any case, why not just use jQuery.noConflict()?
[jQuery] Re: jQuery and Javascript timer question
Here is the most recent code http://pastie.org/376427 If I could only get "\$(this).css({ backgroundColor:color });" to work, I would be happy? Please help me :D Thanks! On Jan 31, 5:57 pm, "thertze...@gmail.com" wrote: > What I'm trying to do is on click of a div spawn a > "timer" (setTimeout) which will run while the user is on the page, on > completion of the countedown of setTimeout, load a function to do a > submit. However in my testing the following code does not wait, and > submits the page event right away. Basically I want to be able to que > up the click events and then process them during an idle few seconds. > > Check out my code below maybe you can help! > > > var pixelid = new Array(); > var pixelcolors = new Array(); > var processTimerId = 0; > var counter = 0; > \$('#result').click(function(e) { > if ( \$(e.target).is('.btn px') ) > { > var color = \$("input#color_code").val(); > \$(this).css({ backgroundColor:color }); > var id_select = \$(e.target).parent('div').attr('id'); > > pixelid[counter] = id_select; > pixelcolors[counter] = color; > > if (counter == 0) > { > //They have not clicked before, so we are ready to > start the > process timer > processTimerId = setTimeout (process_pixels(), 4000); > } > else > { > //They have clicked before, but apparently they > clicked again, stop > the timer and we will restart it. > clearTimeout( processTimerId ); > processTimerId = setTimeout (process_pixels(), 4000); > } > counter++; > > } > > }); > > function process_pixels(){ > > var process_counter = 0; > > while (process_counter <= counter) > { > \$("#result").load('/px_creator.pl', {colorselect: pixelcolors > [process_counter], id_select: pixelid[process_counter]}); > process_counter++; > }} > > > > Example:http://pixelated.hertzelle.com/draw.pl > > Can anyone tell me why my timer process doesnt work as I would want it > to? I still have more work to go...But this has me a bit stuck. Any > help would make me very happy, thanks!
[jQuery] Re: jQuery and Javascript timer question
\$(this).css({ backgroundColor:color }); never seem to fire, as far as I know though, its valid jquery javascript... As for the statement above "("input#color_code").val() " is whatever the user selects from the color picker. If anyone is questioning my \$ in my javascript, i have to do it this way, because I'm running this with a Perl script, and perl uses $ to define and use variables. On Jan 31, 10:15 pm, Dave Methvin wrote: > > Can someone tell me why my \$(this).css({ backgroundColor:color }); > > statement isn't changing as soon as the user clicks on a div? > > Does it fire at some later time, or never? What is the value of $ > ("input#color_code").val() ?
[jQuery] Re: jQuery and Javascript timer question
Can someone tell me why my \$(this).css({ backgroundColor:color }); statement isn't changing as soon as the user clicks on a div? On Jan 31, 5:57 pm, "thertze...@gmail.com" wrote: > What I'm trying to do is on click of a div spawn a > "timer" (setTimeout) which will run while the user is on the page, on > completion of the countedown of setTimeout, load a function to do a > submit. However in my testing the following code does not wait, and > submits the page event right away. Basically I want to be able to que > up the click events and then process them during an idle few seconds. > > Check out my code below maybe you can help! > > > var pixelid = new Array(); > var pixelcolors = new Array(); > var processTimerId = 0; > var counter = 0; > \$('#result').click(function(e) { > if ( \$(e.target).is('.btn px') ) > { > var color = \$("input#color_code").val(); > \$(this).css({ backgroundColor:color }); > var id_select = \$(e.target).parent('div').attr('id'); > > pixelid[counter] = id_select; > pixelcolors[counter] = color; > > if (counter == 0) > { > //They have not clicked before, so we are ready to > start the > process timer > processTimerId = setTimeout (process_pixels(), 4000); > } > else > { > //They have clicked before, but apparently they > clicked again, stop > the timer and we will restart it. > clearTimeout( processTimerId ); > processTimerId = setTimeout (process_pixels(), 4000); > } > counter++; > > } > > }); > > function process_pixels(){ > > var process_counter = 0; > > while (process_counter <= counter) > { > \$("#result").load('/px_creator.pl', {colorselect: pixelcolors > [process_counter], id_select: pixelid[process_counter]}); > process_counter++; > }} > > > > Example:http://pixelated.hertzelle.com/draw.pl > > Can anyone tell me why my timer process doesnt work as I would want it > to? I still have more work to go...But this has me a bit stuck. Any > help would make me very happy, thanks!
[jQuery] Re: jQuery and Javascript timer question
I think i finally got it to work, changed all the setTimeout functions to setInterval, now I just need to figure out why "\$(this).css ({ backgroundColor:color }); " isnt setting the color of the divs instantly, as well as a new method call for .load (don't need to reload everytime with client side color changes, and then finally I need to tweet my timeout time. Thank you all for looking! On Jan 31, 5:57 pm, "thertze...@gmail.com" wrote: > What I'm trying to do is on click of a div spawn a > "timer" (setTimeout) which will run while the user is on the page, on > completion of the countedown of setTimeout, load a function to do a > submit. However in my testing the following code does not wait, and > submits the page event right away. Basically I want to be able to que > up the click events and then process them during an idle few seconds. > > Check out my code below maybe you can help! > > > var pixelid = new Array(); > var pixelcolors = new Array(); > var processTimerId = 0; > var counter = 0; > \$('#result').click(function(e) { > if ( \$(e.target).is('.btn px') ) > { > var color = \$("input#color_code").val(); > \$(this).css({ backgroundColor:color }); > var id_select = \$(e.target).parent('div').attr('id'); > > pixelid[counter] = id_select; > pixelcolors[counter] = color; > > if (counter == 0) > { > //They have not clicked before, so we are ready to > start the > process timer > processTimerId = setTimeout (process_pixels(), 4000); > } > else > { > //They have clicked before, but apparently they > clicked again, stop > the timer and we will restart it. > clearTimeout( processTimerId ); > processTimerId = setTimeout (process_pixels(), 4000); > } > counter++; > > } > > }); > > function process_pixels(){ > > var process_counter = 0; > > while (process_counter <= counter) > { > \$("#result").load('/px_creator.pl', {colorselect: pixelcolors > [process_counter], id_select: pixelid[process_counter]}); > process_counter++; > }} > > > > Example:http://pixelated.hertzelle.com/draw.pl > > Can anyone tell me why my timer process doesnt work as I would want it > to? I still have more work to go...But this has me a bit stuck. Any > help would make me very happy, thanks!
[jQuery] jQuery and Javascript timer question
What I'm trying to do is on click of a div spawn a "timer" (setTimeout) which will run while the user is on the page, on completion of the countedown of setTimeout, load a function to do a submit. However in my testing the following code does not wait, and submits the page event right away. Basically I want to be able to que up the click events and then process them during an idle few seconds. Check out my code below maybe you can help! var pixelid = new Array(); var pixelcolors = new Array(); var processTimerId = 0; var counter = 0; \$('#result').click(function(e) { if ( \$(e.target).is('.btn px') ) { var color = \$("input#color_code").val(); \$(this).css({ backgroundColor:color }); var id_select = \$(e.target).parent('div').attr('id'); pixelid[counter] = id_select; pixelcolors[counter] = color; if (counter == 0) { //They have not clicked before, so we are ready to start the process timer processTimerId = setTimeout (process_pixels(), 4000); } else { //They have clicked before, but apparently they clicked again, stop the timer and we will restart it. clearTimeout( processTimerId ); processTimerId = setTimeout (process_pixels(), 4000); } counter++; } }); function process_pixels(){ var process_counter = 0; while (process_counter <= counter) { \$("#result").load('/px_creator.pl', {colorselect: pixelcolors [process_counter], id_select: pixelid[process_counter]}); process_counter++; } } Example: http://pixelated.hertzelle.com/draw.pl Can anyone tell me why my timer process doesnt work as I would want it to? I still have more work to go...But this has me a bit stuck. Any help would make me very happy, thanks!