[jQuery] Re: conditional events
I'm trying to trigger an event only when a condition is met, $(document).ready(function() { $('#leftScroll').click(function() { $('#scrollContent') .animate( { left: '+=900' }, 'slow'); }); }); I only want '#scrollContent' to move if its position is not 'left: 10' I've tried using .offset() and .position() both with no luck if($('#scrollContent').position() != left: 10) { do stuff} else { do nothing } I'm familiar with ActionScript conditional principles but I get no results when I try here. any help would be greatly appreciated... maybe this? if ( $('#scrollContent').css('left') != 10) ) { // do stuff }
[jQuery] Re: Conditional events
Thank you! Works great now :) Leon. Mika Tuupola wrote: On Dec 21, 2007, at 9:32 PM, LeonL wrote: This will work fine - alert the edit var value. However, when adding 'event: edit' it wont do a thing: $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250, event: edit }).bind(click,function() { alert(edit) }); Is there something I'm doing wrong? Thanks! Sorry it took awhile. Just came back from christmas travels. Make sure you are using recent version of Jeditable. Latest here: http://www.appelsiini.net/download/jquery.jeditable-1.5.2.js -- Mika Tuupola http://www.appelsiini.net/ -- View this message in context: http://www.nabble.com/Conditional-events-tp14453255s27240p14604750.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: Conditional events
On Dec 21, 2007, at 9:32 PM, LeonL wrote: This will work fine - alert the edit var value. However, when adding 'event: edit' it wont do a thing: $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250, event: edit }).bind(click,function() { alert(edit) }); Is there something I'm doing wrong? Thanks! Sorry it took awhile. Just came back from christmas travels. Make sure you are using recent version of Jeditable. Latest here: http://www.appelsiini.net/download/jquery.jeditable-1.5.2.js -- Mika Tuupola http://www.appelsiini.net/
[jQuery] Re: Conditional events
On Dec 21, 2007, at 12:24 PM, LeonL wrote: Hello everyone. I've been trying for some time now to make this code to execute ONLY if a variable called edit equals to 1: The code: $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250 });//EOE Does anybody have an idea how to do that?? Thanks. This is one way to do it: -cut- var check = 1; $(.item_title).editable(?php print $url ?echo.php, { event : edit, }).bind(click, function() { if (check) { $(this).trigger(edit); } }); -cut- Basically it binds custom event edit to start Jeditable. Then after click it check if variable check is true. If it is it triggers edit event on Jeditable. -- Mika Tuupola http://www.appelsiini.net/
[jQuery] Re: Conditional events
Thanks Mika, but it doesn't seem to work for me :( What I did is (for testing): $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250, }).bind(click,function() { alert(edit) }); This will work fine - alert the edit var value. However, when adding 'event: edit' it wont do a thing: $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250, event: edit }).bind(click,function() { alert(edit) }); Is there something I'm doing wrong? Thanks! Mika Tuupola wrote: On Dec 21, 2007, at 12:24 PM, LeonL wrote: Hello everyone. I've been trying for some time now to make this code to execute ONLY if a variable called edit equals to 1: The code: $(.item_title).editable(operator.php,{ submitdata: {'type': 'title'}, width: 250 });//EOE Does anybody have an idea how to do that?? Thanks. This is one way to do it: -cut- var check = 1; $(.item_title).editable(?php print $url ?echo.php, { event : edit, }).bind(click, function() { if (check) { $(this).trigger(edit); } }); -cut- Basically it binds custom event edit to start Jeditable. Then after click it check if variable check is true. If it is it triggers edit event on Jeditable. -- Mika Tuupola http://www.appelsiini.net/ -- View this message in context: http://www.nabble.com/Conditional-events-tp14453255s27240p14461121.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.