[jQuery] Re: Callback not firing
You said I get the log entry in the console. You have two in there. Which one? Both? If you get the log entry Show Testimonial Fired? If so, then it did fire. It's something else that didn't work as expected, but perhaps made you to believe the callback did not fire. On Oct 21, 5:04 am, Sir Rawlins robert.rawl...@thinkbluemedia.co.uk wrote: Hello Guys, I'm sure that I'm doing something blatantly wrong here but I can't spot what's wrong. I've got the following code snippet. http://pastebin.com/m71102c16 Now, when calling the method change_testimonial() I get the log entry in the console as expected however the callback to show_new_testimonial () after the fade out occurs doesn't appear to get fired. Can anyone offer any suggestions? I know that the show_new_testimonial () method works when called independently so I'm guessing this is just a syntax issue on my part for the callback. Thanks, Rob
[jQuery] Re: Callback for selected match
I'm not sure what you are talking about. Are you talking about a specific jQuery plug-in? Or a HTML select drop-down? If you're talking about a HTML select, then an onchange event will do what you want. $(select).change(function() { alert( $(this).val() ); }); On Oct 14, 10:24 am, eka ekagauranga...@gmail.com wrote: Hi Is there anyway to pass a callback to the options to be called when an option is selected? Regards Eka
[jQuery] Re: Callback Function had a look but don't get it
the link should have it's normal state and actions when you don't return false, as in the example code you provided. If you want to add a call back to fire after the fade out: $(function() { // document is ready for load $('a').click(function() { $('.box').fadeOut(slow, function(){ callback(); }); }); }); regards, Jon 2009/10/1 jessie mi...@optusnet.com.au Ok i'm nearly there LOL i have the link and a box which i want to foundOut as my function. All works dandy now :) But whatif i wanted after i clicked on the link to go to its normal state? Well i went to the jquery site but i don't think its designed for TRUE beginners like myself It talks about Callback function and its displayed like this function callback() { this; // dom element } So here is my code and where do i put this callBack? and do i need to add a class to it? $(function() { // document is ready for load $('a').click(function() { $('.box').fadeOut(slow); }); }); Jessie
[jQuery] Re: Callback Not Working
Aaron - Thanks so much, that works like a champ. I never thought of the fact that the this pointer was changing context. Thanks so much for the code and the explanation, that knowledge is very helpful. Cheers - george On Aug 24, 7:00 pm, Aaron Gundel aaron.gun...@gmail.com wrote: Hi George, It appears that your code isn't working because the context of your this pointer changes in the callback inside of your fadeout effect. it becomes your section title. So when you do a find on it, you find only children of the section title that are of the class explanation -- which don't exist, hence your problem. Using siblings should solve the issue. Try the following code. Note that I've changed your mouseove to a mouseleave, since mouseover appears to fire too frequently. Hope this helps, or at least gets you on your way function() { $('li').mouseover( function() { $(this).find('div.SectionTitle').fadeOut('fast', function() { $(this).siblings('div.Explanation').fadeIn('slow'); }); }); $('li').mouseleave( function() { $(this).find('div.Explanation').fadeOut('fast', function () { $(this).siblings('div.SectionTitle').fadeIn('slow'); }); }); } Aaron On Mon, Aug 24, 2009 at 5:16 AM, GLSmythgeorge.sm...@gmail.com wrote: I am looking to fade text out when the mouse passes over it and replace it with text that is faded in. My understanding is that this needs to be done through a callback, as the text needs to fade out completely before fading in. However, when I try to implement this idea the content does not fade in, so I must be doing something wrong. My code is: script type=text/javascript var Tips = { ready: function() { $('ul#SiteNav li').mouseover( function() { $(this).find('div.SectionTitle').fadeOut('fast', function () { $(this).find('div.Explanation').fadeIn('slow'); }); }); $('ul#SiteNav li').mouseout( function() { $(this).find('div.Explanation').hide(); $(this).find('div.SectionTitle').show(); }) } }; $(document).ready(Tips.ready); /script I left the mouseout part unchanged, as that is an example of what I am changing from. What happens is that the mouseover text fades out, but the replaced text does not fade back in. Additionally, the shown text flashes before fading out if the mouse rolls over the text (as opposed to the containing box), which is not really a problem, but I am not understanding why that is happening. All works fine with hide/show. Full code can be found athttp://dripinvesting.org/Default_test.asp. I am apparently missing something basic, so a pointer to a beginner would be appreciated. Cheers - george
[jQuery] Re: Callback Not Working
Hi George, It appears that your code isn't working because the context of your this pointer changes in the callback inside of your fadeout effect. it becomes your section title. So when you do a find on it, you find only children of the section title that are of the class explanation -- which don't exist, hence your problem. Using siblings should solve the issue. Try the following code. Note that I've changed your mouseove to a mouseleave, since mouseover appears to fire too frequently. Hope this helps, or at least gets you on your way function() { $('li').mouseover( function() { $(this).find('div.SectionTitle').fadeOut('fast', function() { $(this).siblings('div.Explanation').fadeIn('slow'); }); }); $('li').mouseleave( function() { $(this).find('div.Explanation').fadeOut('fast', function () { $(this).siblings('div.SectionTitle').fadeIn('slow'); }); }); } Aaron On Mon, Aug 24, 2009 at 5:16 AM, GLSmythgeorge.sm...@gmail.com wrote: I am looking to fade text out when the mouse passes over it and replace it with text that is faded in. My understanding is that this needs to be done through a callback, as the text needs to fade out completely before fading in. However, when I try to implement this idea the content does not fade in, so I must be doing something wrong. My code is: script type=text/javascript var Tips = { ready: function() { $('ul#SiteNav li').mouseover( function() { $(this).find('div.SectionTitle').fadeOut('fast', function () { $(this).find('div.Explanation').fadeIn('slow'); }); }); $('ul#SiteNav li').mouseout( function() { $(this).find('div.Explanation').hide(); $(this).find('div.SectionTitle').show(); }) } }; $(document).ready(Tips.ready); /script I left the mouseout part unchanged, as that is an example of what I am changing from. What happens is that the mouseover text fades out, but the replaced text does not fade back in. Additionally, the shown text flashes before fading out if the mouse rolls over the text (as opposed to the containing box), which is not really a problem, but I am not understanding why that is happening. All works fine with hide/show. Full code can be found at http://dripinvesting.org/Default_test.asp. I am apparently missing something basic, so a pointer to a beginner would be appreciated. Cheers - george
[jQuery] Re: Callback function after switchClass()
Hi. What type of animation will you be making ? I could help :) On Tue, May 12, 2009 at 9:30 PM, kgosser kgos...@gmail.com wrote: Hey all, I'm trying to do some animation designs. Basically where I'm stuck is I have a bunch of things I want to do, but not until the duration of the switchClass method is complete. Looking at the UI documentation site, there doesn't appear to be a callback ability. Anyone have any tips on how I can make a callback on the switchClass? Thanks.
[jQuery] Re: Callback function after switchClass()
here is one way to create delay setTimeout(function() { // do function after 0.5 seconds }, 500); On Tue, May 12, 2009 at 9:32 PM, waseem sabjee waseemsab...@gmail.comwrote: Hi. What type of animation will you be making ? I could help :) On Tue, May 12, 2009 at 9:30 PM, kgosser kgos...@gmail.com wrote: Hey all, I'm trying to do some animation designs. Basically where I'm stuck is I have a bunch of things I want to do, but not until the duration of the switchClass method is complete. Looking at the UI documentation site, there doesn't appear to be a callback ability. Anyone have any tips on how I can make a callback on the switchClass? Thanks.
[jQuery] Re: Callback functions
When using a second object for the options, the callback must be defined in it, like this: .animate({ top : '1038px', left : '247px' }, { duration: 1400, easing:'easeInOutQuad', complete: function() { $('#anim_talkBubble') .fadeIn(1000) .animate({top : '955px'}, 1000) .fadeOut(1000); }); On Mar 26, 4:29 pm, Mike mcpat...@gmail.com wrote: Anyone know why the callback function here isn't working? $('#anim_flipper') .animate( {top : '1130px'}, {queue:false, duration: 1100} ) .animate( {left : '335px'}, {duration: 1400, easing:'easeInOutQuad'} ) .animate( {top : '1126px', left : '339px'}, { duration: 600, easing:'easeOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1130px', left : '335px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1130px', left : '335px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 600, easing:'easeInOutQuad'} ) .animate( {top : '1038px', left : '247px'}, { duration: 1400, easing:'easeInOutQuad'}, function() { $('#anim_talkBubble').fadeIn(1000).animate( {top : '955px'}, 1000).fadeOut(1000); } );
[jQuery] Re: Callback functions
for me it works like this: $('#anim_flipper').animate({top: '1130px'}, { duration: 1100}) .animate({left: '335px'}, {duration: 1400}, {easing:'easeInOutQuad'}) .animate({top: '1126px', left: '339px'}, { duration: 600}, {easing:'easeOutQuad'}) .animate({top: '1142px', left: '330px'}, { duration: 900}, {easing:'easeInOutQuad'}) .animate({top: '1130px', left: '335px'}, { duration: 900}, {easing:'easeInOutQuad'}) .animate({top: '1142px', left: '330px'}, { duration: 900}, {easing:'easeInOutQuad'}) .animate({top: '1130px', left: '335px'}, { duration: 900}, {easing:'easeInOutQuad'}) .animate({top: '1142px', left: '330px'}, { duration: 600}, {easing:'easeInOutQuad'}) .animate({top: '1038px', left: '247px'}, 1400,function() { $('#anim_talkBubble').fadeIn(1000).animate({top : '955px'}, 1000).fadeOut(1000); }); On 26 Mrz., 20:29, Mike mcpat...@gmail.com wrote: Anyone know why the callback function here isn't working? $('#anim_flipper') .animate( {top : '1130px'}, {queue:false, duration: 1100} ) .animate( {left : '335px'}, {duration: 1400, easing:'easeInOutQuad'} ) .animate( {top : '1126px', left : '339px'}, { duration: 600, easing:'easeOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1130px', left : '335px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1130px', left : '335px'}, { duration: 900, easing:'easeInOutQuad'} ) .animate( {top : '1142px', left : '330px'}, { duration: 600, easing:'easeInOutQuad'} ) .animate( {top : '1038px', left : '247px'}, { duration: 1400, easing:'easeInOutQuad'}, function() { $('#anim_talkBubble').fadeIn(1000).animate( {top : '955px'}, 1000).fadeOut(1000); } );
[jQuery] Re: callback function
The syntax would be like $(#gallery-flickr).flickr({ api_key: f28804be7a09c5845676349c7e47d636, per_page: 4, callback: function() { $('a').attr({ rel: prettyPhoto}); } }); On Feb 24, 11:57 pm, mlabee01 mari...@savariba.com wrote: Hello, I’m pretty new in the jQuery world. I'm struggle with the callback function. script type=text/javascript $(document).ready(function(){ $(#gallery-flickr).flickr({api_key: f28804be7a09c5845676349c7e47d636,per_page: 4 }); $('a').attr({ rel: prettyPhoto}); }); /script In the first line 4 photos are retrieved from flickr. In the second line rel: prettyPhoto has been added to the 4 received photo lines from flickr. This action must perform after all the photo info has been received. It is my understanding that this can be done via the callback function. Albeit I understand the idea behind the callback I do not understand the syntax. What I really want is that the action =$ ('a').attr({ rel: prettyPhoto});= has been performed when the first action = $(#gallery-flickr).flickr({api_key: f28804be7a09c5845676349c7e47d636,per_page: 4 });= has been finished. Any help will appreciated Marinus
[jQuery] Re: Callback from the $.post function is not being invoked
Ah! Some helpful individual here in Philadelphia posted a clue for me on the PANMA list and I've evolved his suggestion into this code which works like magic: function edit_event_handlers( ) { // highlight the field backgrounds when the user enters it for ( var target in datafields ) { $(datafields[target]).focus( function(dt,ft) { return function() { $(dt).css('background-color','#FDD') ; $(ft).css('background-color','#FDD') ; } ; }(datafields[target], fieldfields[target]) ) ; // restore the field backgrounds when the user exits it $(datafields[target]).blur( function(dt,ft) { return function() { $(dt).css('background-color','#EFE') ; $(ft).css('background-color','#EFE') ; } ; }(datafields[target], fieldfields[target]) ) ; // Set the handler for the onChange event $(datafields[target]).change(function(event) { dft = # + this.id ; $(this).css('background-color', 'orange'); fft = # + this.id.replace('data','field') ; $(fft).css('background-color', 'orange'); $.post(/index.php/Workflow_server/updatefield/, {fieldname: mapping[this.id], fieldval: $(this).val ()}, function() { $(dft).css('background-color', '#AAF' ) ; $(fft).css('background-color', '#AAF' ) ; } ); }); } ; } The data arrays are missing from this code snippet but the key was understanding that closures were not needed - I can just use this which jQuery sets for me. Still learnin'... this is great! Eric
[jQuery] Re: callback for append function?
The append is done immediately, but you have to wait for the load event of the image before you can get the correct height. by(e) Stephan 2009/2/2 lhwpa...@googlemail.com lhwpa...@googlemail.com: is there any way to get a callback when append is ready? i have the following problem. i add some images with .append() after this i have to get the .height() of these images. when i now execute .append() it takes a while to load the images so the .height() function can not find the images.
[jQuery] Re: callback for append function?
You can make a function you call every time an image has been loaded and update a counter in this function. Once the counter reaches the number if images you have on your page, you know that all images where loaded. see: http://jsbin.com/ofici/edit by(e) Stephan 2009/2/2 Liam Potter radioactiv...@gmail.com: can you please not delete the quoted message, as I have no idea what you just thanked someone for now. lhwpa...@googlemail.com wrote: great! thanks for that! one last question. is it possible to fire a function when the last of 5 images is loaded ?
[jQuery] Re: callback for append function?
great! thanks for that! one last question. is it possible to fire a function when the last of 5 images is loaded ?
[jQuery] Re: callback for append function?
ok thanks, and is there any way to use the load event to an image included with append?
[jQuery] Re: callback for append function?
can you please not delete the quoted message, as I have no idea what you just thanked someone for now. lhwpa...@googlemail.com wrote: great! thanks for that! one last question. is it possible to fire a function when the last of 5 images is loaded ?
[jQuery] Re: callback for append function?
sure, no problem take a look at: http://jsbin.com/udeze/edit by(e) Stephan 2009/2/2 lhwpa...@googlemail.com lhwpa...@googlemail.com: ok thanks, and is there any way to use the load event to an image included with append?
[jQuery] Re: callback for append function?
Take notice that the image's load event doesn't always fire in IE. You have to use .bind('readystatechange load', loaded) function loaded(){ if (this.complete) // or if (this.readyState == 'complete') //do stuff to guarantee that the function will be called (the .complete property is always true on FF, and it doesnt fire readystatechange for images). cheers, - ricardo On Feb 2, 4:17 pm, Stephan Veigl stephan.ve...@gmail.com wrote: You can make a function you call every time an image has been loaded and update a counter in this function. Once the counter reaches the number if images you have on your page, you know that all images where loaded. see:http://jsbin.com/ofici/edit by(e) Stephan 2009/2/2 Liam Potter radioactiv...@gmail.com: can you please not delete the quoted message, as I have no idea what you just thanked someone for now. lhwpa...@googlemail.com wrote: great! thanks for that! one last question. is it possible to fire a function when the last of 5 images is loaded ?
[jQuery] Re: callback :passing $_POST values after completing form
If you're using a straight-forward form submission, make the form action submit to a script and process it server-side. If you're doing it through AJAX, the following Jquery functions maybe of use to you: serialize() : http://docs.jquery.com/Ajax/serialize serializeArray() : http://docs.jquery.com/Ajax/serializeArray On Jan 30, 2:12 am, dimitri megak...@gmail.com wrote: i'm all new with jquery and i'm using a validator for my form from marzapower. i was lucky enough to make the script detemine whether the form is fulfilled correctly or not whan not it sasy forgotten this or that, when correct it says i made it. but i'm now struggling om how i have to pass the data to my page for processing en INSERT/UPDATE my database Has anyone suggestions on how to solve this
[jQuery] Re: Callback function not working
haven't tested it, bu I guess the this variable is the problem in your callback $(#date_+$(this).attr(id)).html(Done!); try: var el = $(this); $.post(includes/updateleverans.php,{id:el.attr(id), date:date}, function (data) { $(#date_+el.attr(id)).html(Done!); }); by(e) Stephan 2009/1/24 Althalos ca...@ekdahlproduction.com: and also $(#date_+$(this).attr(id)).html(Updating..); works fine! On 24 Jan, 16:39, Althalos ca...@ekdahlproduction.com wrote: Hello, I have a callback function belonging to a $.post that won't work. Anyone know why? This is my function: function(date) { $(#date_+$(this).attr(id)).html(Updating..); $.post(includes/updateleverans.php,{id:$(this).attr(id), date:date}, function (data) { $(#date_+$(this).attr(id)).html(Done!); }); } This is my php: ?php include (db_connect.inc); $date = str_replace(-, /, $_POST['date']); $id = $_POST['id']; mysql_query(UPDATE prot_orders SET due_date = '$date' WHERE id = '$id'); echo ($date); ? The MySQL query executes SUCCESFULLY and $date is set correctly.. please anyone?
[jQuery] Re: Callback function not working
and also $(#date_+$(this).attr(id)).html(Updating..); works fine! On 24 Jan, 16:39, Althalos ca...@ekdahlproduction.com wrote: Hello, I have a callback function belonging to a $.post that won't work. Anyone know why? This is my function: function(date) { $(#date_+$(this).attr(id)).html(Updating..); $.post(includes/updateleverans.php,{id:$(this).attr(id), date:date}, function (data) { $(#date_+$(this).attr(id)).html(Done!); }); } This is my php: ?php include (db_connect.inc); $date = str_replace(-, /, $_POST['date']); $id = $_POST['id']; mysql_query(UPDATE prot_orders SET due_date = '$date' WHERE id = '$id'); echo ($date); ? The MySQL query executes SUCCESFULLY and $date is set correctly.. please anyone?
[jQuery] Re: Callback problem
I have tried this: var handler = editElementName; function editElementNameSave() { alert('Hurray!'); console.log(1); } function showModalBox(handler) { $(.1).click(function(){ console.log(2); (handler + Save)(); }); console.log(3); } $(document).ready(function(){ showModalBox(handler); }); And I got editElementNameSave is not a function error !!! Error refers to line - (handler + Save)(); Read jQuery HowTo Resource - http://jquery-howto.blogspot.com On Thu, Jan 22, 2009 at 1:15 PM, Alex Sergeev sergeev.sa...@gmail.com wrote: Hello! i have a code var handler = editElementName; function showModalBox(width, height, handler, id) { ... $(.btnSave).click(handler + Save); ... } function editElementNameSave(e) { alert(1); } Why dont work event click? PS sorry for my English - i am from Russia
[jQuery] Re: Callback problem
Alex's code was doing the equivalent of: $(.btnSave).click(editElementNameSave); The click() function, like all event functions, expects to receive a *reference* to a function, not the *name* of a function. Your code is doing the equivalent of: editElementNameSave(); You can't call a string as if it were a function. If editElementNameSave() is a global function (not nested inside another function), you can do: $(.btnSave).click( window[handler+'Save'] ); Alex, if you could explain the purpose of the code and give a more complete example, there may be a better way to do it. -Mike From: jQuery Lover I have tried this: var handler = editElementName; function editElementNameSave() { alert('Hurray!'); console.log(1); } function showModalBox(handler) { $(.1).click(function(){ console.log(2); (handler + Save)(); }); console.log(3); } $(document).ready(function(){ showModalBox(handler); }); And I got editElementNameSave is not a function error !!! Error refers to line - (handler + Save)(); Read jQuery HowTo Resource - http://jquery-howto.blogspot.com On Thu, Jan 22, 2009 at 1:15 PM, Alex Sergeev sergeev.sa...@gmail.com wrote: Hello! i have a code var handler = editElementName; function showModalBox(width, height, handler, id) { ... $(.btnSave).click(handler + Save); ... } function editElementNameSave(e) { alert(1); } Why dont work event click? PS sorry for my English - i am from Russia
[jQuery] Re: Callback on $.Post not firing
Is it maybe generating an error? Try converting to a .ajax call so that you've got access to the error method handlers. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rage9 Sent: Monday, November 24, 2008 3:43 PM To: jQuery (English) Subject: [jQuery] Callback on $.Post not firing This is driving me loopy. Simple post, trying to get a result back from the server. Heck even copied it from the documentation and the callback just will not fire, but the post works fine: var answer = confirm(Delete Selected?); if (answer){ $.post(test.php, { name: test }, function(data){ alert(popped off!); alert(data.name); // John console.log(data.time); // 2pm }, json); } PHP: ?php echo json_encode(array(name=John,time=2pm)); ? I also tried with XML with no luck either. Firebug doesn't seem to show a response, but I know the post variables are passed just fine, because I wrote a logger [not included] to tell me what the variables where being passed. No dice on the return info. Tried this with both firefox and opera and in neither the call-backe worked. Ideas?
[jQuery] Re: Callback on $.Post not firing
Ok did that but still not getting anything from the errors: $.ajax({ type: POST, url: test.php, data: {name: test}, dataType: json, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest: + XMLHttpRequest); alert(textStatus: + textStatus); alert(errorThrown: + errorThrown); }, success: function(msg){ alert( Data Saved: + msg ); } }); XMLHttpRequest: XMLHttpRequest object; textStatus: error; and errorThrown: undefined Am I going about this the wrong way? On Nov 24, 3:47 pm, Andy Matthews [EMAIL PROTECTED] wrote: Is it maybe generating an error? Try converting to a .ajax call so that you've got access to the error method handlers. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rage9 Sent: Monday, November 24, 2008 3:43 PM To: jQuery (English) Subject: [jQuery] Callback on $.Post not firing This is driving me loopy. Simple post, trying to get a result back from the server. Heck even copied it from the documentation and the callback just will not fire, but the post works fine: var answer = confirm(Delete Selected?); if (answer){ $.post(test.php, { name: test }, function(data){ alert(popped off!); alert(data.name); // John console.log(data.time); // 2pm }, json); } PHP: ?php echo json_encode(array(name=John,time=2pm)); ? I also tried with XML with no luck either. Firebug doesn't seem to show a response, but I know the post variables are passed just fine, because I wrote a logger [not included] to tell me what the variables where being passed. No dice on the return info. Tried this with both firefox and opera and in neither the call-backe worked. Ideas?
[jQuery] Re: callback after insertBefore or insertAfter is complete;
Regular DOM manipulation events (that is, not .load(), which uses Ajax) are synchronous, so you can simply call your function on the next line. - Richard On Wed, Oct 29, 2008 at 9:22 AM, gryzzly [EMAIL PROTECTED] wrote: Hello. I need to call function after $(#element).insertBefore(a href=#' title='prev'prev/a). I was trying $(#element).insertBefore(a href=#' title='prev'prev/ a, callback_function); but it didn't work. What can I do to achieve this? Thank you.
[jQuery] Re: callback after insertBefore or insertAfter is complete;
Thank You a lot. On Oct 29, 3:55 pm, Richard D. Worth [EMAIL PROTECTED] wrote: Regular DOM manipulation events (that is, not .load(), which uses Ajax) are synchronous, so you can simply call your function on the next line. - Richard On Wed, Oct 29, 2008 at 9:22 AM, gryzzly [EMAIL PROTECTED] wrote: Hello. I need to call function after $(#element).insertBefore(a href=#' title='prev'prev/a). I was trying $(#element).insertBefore(a href=#' title='prev'prev/ a, callback_function); but it didn't work. What can I do to achieve this? Thank you.
[jQuery] Re: Callback to home page from 2nd page
Hi! Could you rephrase your question? On Sep 25, 4:14 am, Reddy [EMAIL PROTECTED] wrote: Could somebody help me in this issue. when I am on landing page I have two questions to be answered . When I click on 2nd ques which is radio button i will be shown with other remaining questions. So from 2nd page when i click on link which takes me to homepage I want that exact page which i will be prompted when i try to access my application.
[jQuery] Re: Callback to home page from 2nd page
After submittinh home page I will be redirected to next page . So Upon clicking Start again I should be redirected to HomePage with only two questions to be displayed instead of all. On Fri, Sep 26, 2008 at 1:45 AM, ricardobeat [EMAIL PROTECTED] wrote: Hi! Could you rephrase your question? On Sep 25, 4:14 am, Reddy [EMAIL PROTECTED] wrote: Could somebody help me in this issue. when I am on landing page I have two questions to be answered . When I click on 2nd ques which is radio button i will be shown with other remaining questions. So from 2nd page when i click on link which takes me to homepage I want that exact page which i will be prompted when i try to access my application.
[jQuery] Re: Callback to home page from 2nd page
Sounds like something that should be done server-side with a database. Anyway, the only way to pass javascript data to another page is via the location.hash (http://page.com/ index.htm#data1=yuck,data2=yack,data3=yock). You turn the data into a string, attach it to an a href= or directly change the location.href in your script. Then you get the value from location.hash in the other page and split the string according to the format you used to get a data array. On 25 set, 20:37, Kavitha reddy [EMAIL PROTECTED] wrote: After submittinh home page I will be redirected to next page . So Upon clicking Start again I should be redirected to HomePage with only two questions to be displayed instead of all. On Fri, Sep 26, 2008 at 1:45 AM, ricardobeat [EMAIL PROTECTED] wrote: Hi! Could you rephrase your question? On Sep 25, 4:14 am, Reddy [EMAIL PROTECTED] wrote: Could somebody help me in this issue. when I am on landing page I have two questions to be answered . When I click on 2nd ques which is radio button i will be shown with other remaining questions. So from 2nd page when i click on link which takes me to homepage I want that exact page which i will be prompted when i try to access my application.
[jQuery] Re: callback executed before effect ended
problem is that next element appears while current element is still fading out, any idea what i'm doing wrong? Maybe you could add display:none; to the current css class. Paul
[jQuery] Re: Callback-return into global variable
Couple of thoughts: 1) $.each() is not for moving through an array. (is for doing something to each matched DOM element) try: for(item in _json) { alert('item:'+item);} 2) try defining your global as an object. e.g. var _json = {}; -jason On Jan 16, 2:17 am, Niels [EMAIL PROTECTED] wrote: Is there any way to put a return from within a callback into a global variable? I'm trying to retrieve JSON-values in one statement, and output them in another statement; and code looks like this: var _json; function load_comments(id, params) { if (typeof id != 'number' typeof id == 'object' params == null) { // Only the params were specified. _params = process_params(id); $.getJSON(paths.get_comment, _params, function(data) { _json = data; return _json; }); console.info('1 : $.getJSON(' + paths.get_comment + ', ' + _params + ')'); } } function display_comments() { load_comments(); $.each(_json.comments, function(comment) { $(#recent-comments-list).append(li + comment.content + / li); }); } Unfortunately, _json seems to remain undefined... What am I doing wrong? Or is there really no way to accomplish this? Thanks a lot! Niels
[jQuery] Re: Callback-return into global variable
$.getJSON and all the AJAX functions are asynchronous; the function returns before it gets any result. That's why there's a callback function: it gets called when the data are available. So when you write load_comments(); $.each(_json.comments, function(comment) { load_comments() just sets up the AJAX call and returns, so the each starts with _json not yet initialized. You can get around it by using asynch: false in a $.ajax call (see the documentation), but that's not the ideal solution. Better to put your $.each into the callback function: $.getJSON(paths.get_comment, _params, function(data) { $.each (data.comments, function (comment){...}) }); Danny On Jan 16, 1:17 am, Niels [EMAIL PROTECTED] wrote: Is there any way to put a return from within a callback into a global variable? I'm trying to retrieve JSON-values in one statement, and output them in another statement; and code looks like this: var _json; function load_comments(id, params) { if (typeof id != 'number' typeof id == 'object' params == null) { // Only the params were specified. _params = process_params(id); $.getJSON(paths.get_comment, _params, function(data) { _json = data; return _json; }); console.info('1 : $.getJSON(' + paths.get_comment + ', ' + _params + ')'); } } function display_comments() { load_comments(); $.each(_json.comments, function(comment) { $(#recent-comments-list).append(li + comment.content + / li); }); } Unfortunately, _json seems to remain undefined... What am I doing wrong? Or is there really no way to accomplish this? Thanks a lot! Niels
[jQuery] Re: Callback after append?
Thats right, the only things that need a callback are ajax and animations (unless im missing something) On 7/25/07, Klaus Hartl [EMAIL PROTECTED] wrote: juliandormon wrote: I'm adding html into a div using append. I want to update my custom scrollbar plugin which is in a parent div after the append has completed loading to accommodate the new height of the content in the child div. What's the proper way of doing a callback after append for a different div? I cannot simply chain this because it's a different div. This is what I have but the callback paramater does not seem to work for append - perhaps it's not a parameter at all? div id=parentDiv class=scrollBar div id= childDiv class=appendedContentGoesHere/div /div $(#childDiv).append('mygreatHTML',function(){$(#parentDiv).updateScrollBar()}) Much appreciated! You don't need a callback, such operations happen one after the other in JavaScript: $(#childDiv).append('mygreatHTML'); $(#parentDiv).updateScrollBar(); You could of course still make a chain: $(#childDiv).append('mygreatHTML').parent().updateScrollBar(); That frees you from having to use another hardcoded id... --Klaus
[jQuery] Re: Callback after append?
Julian, have you tried this? $(#childDiv).append('mygreatHTML').parent().updateScrollBar(); $(#childDiv).append('mygreatHTML',function(){$(#parentDiv).updateScrollBar()})
[jQuery] Re: Callback after append?
I did not know that. That worked great! Klaus Hartl wrote: juliandormon wrote: I'm adding html into a div using append. I want to update my custom scrollbar plugin which is in a parent div after the append has completed loading to accommodate the new height of the content in the child div. What's the proper way of doing a callback after append for a different div? I cannot simply chain this because it's a different div. This is what I have but the callback paramater does not seem to work for append - perhaps it's not a parameter at all? div id=parentDiv class=scrollBar div id= childDiv class=appendedContentGoesHere/div /div $(#childDiv).append('mygreatHTML',function(){$(#parentDiv).updateScrollBar()}) Much appreciated! You don't need a callback, such operations happen one after the other in JavaScript: $(#childDiv).append('mygreatHTML'); $(#parentDiv).updateScrollBar(); You could of course still make a chain: $(#childDiv).append('mygreatHTML').parent().updateScrollBar(); That frees you from having to use another hardcoded id... --Klaus -- View this message in context: http://www.nabble.com/Callback-after-append--tf4146489s15494.html#a11800185 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: callback
Welcome to jQuery! Could you provide some more context to your question? I'm a little confused as to what you are asking about. In general callbacks are used in order to keep things synchronized. Especially things like AJAX and FX. Without callbacks we wouldn't easily be able to know when those items where done executing. -- Brandon Aaron On 5/21/07, james_027 [EMAIL PROTECTED] wrote: Hi, I am welcoming myself to Jquery, and I am glad that I give myself a chance to try jquery. The documentation and tutorials which many seems to ignore is one of the things that makes me to go for jquery for my javascript ajax need. Upon finishing the How jQuery Works, I want to learn why callback should be executed after the parent. As a newbie to javascript/jQuery, I am expecting that the callback should be executed first before the parent. What is the reason or logic behind, and should this be the case everytime? Thanks James
[jQuery] Re: callback
Hi, This is from How jQuery work from John, A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. The special thing about a callback is that functions that appear after the parent can execute before the callback executes. Another important thing to know is how to properly pass the callback. This is where I have often forgotten the proper syntax. Callback with arguments What do you do if you have arguments that you want to pass?, you might ask yourself. Wrong The Wrong Way (will not work!) $.get('myhtmlpage.html', myCallBack(param1, param2)); This will not work because it calls myCallBack(param1, param2) then passes the return value as the second parameter to $.get(). I just want to know why callback behave like that. Is this something a jQuery feature or a javascript feature in general? Thanks On May 21, 8:58 pm, Brandon Aaron [EMAIL PROTECTED] wrote: Welcome to jQuery! Could you provide some more context to your question? I'm a little confused as to what you are asking about. In general callbacks are used in order to keep things synchronized. Especially things like AJAX and FX. Without callbacks we wouldn't easily be able to know when those items where done executing. -- Brandon Aaron On 5/21/07, james_027 [EMAIL PROTECTED] wrote: Hi, I am welcoming myself to Jquery, and I am glad that I give myself a chance to try jquery. The documentation and tutorials which many seems to ignore is one of the things that makes me to go for jquery for my javascript ajax need. Upon finishing the How jQuery Works, I want to learn why callback should be executed after the parent. As a newbie to javascript/jQuery, I am expecting that the callback should be executed first before the parent. What is the reason or logic behind, and should this be the case everytime? Thanks James
[jQuery] Re: callback
On 5/21/07, james_027 [EMAIL PROTECTED] wrote: Wrong The Wrong Way (will not work!) $.get('myhtmlpage.html', myCallBack(param1, param2)); Try this: $.get('myhtmlpage.html', function() { myCallBack(param1, param2); }); Wrapping the call to myCallBack in an anonymous function should fix that issue. -- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com
[jQuery] Re: callback in a plugin
Alexandre Plennevaux ha scritto: i would like to add this to the jqUploader plugin, so that i could do something like: function pleaseDoTheseThings (params){ $(#dothis).show(); } $(input#example1).jqUploader({ background: FF9900, barColor: FFDD00, allowedExt: gif, callBack: pleaseDoTheseThings }); Thanks a lot! Alexandre The principle is quite simple. When the plugin has completed its processing, and it is up to the plugin's author to know when it has, you just call your callback function if setted in the options. Something like this: var options = {callback:function(){alert(I've finished!);}} jQuery.fn.my_plugin_with_callback = function(options) { this.each(function(){ ...do some processing }); if(options.callback) callback(); } Renato
[jQuery] Re: callback in a plugin
Ok, in the meanwhile i found the plugin documentation (sitting right on the homepage, i must had a fit of blindness :)) so i just have to do it as an additional option. Thanks a lot for the clear explanation renato ! I know this sounded like a stupid question, but i'm just not feeling at home with javascript. Although with jquery, i already feel in my county :) -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Renato Formato Sent: lundi 14 mai 2007 16:39 To: jquery-en@googlegroups.com Subject: [jQuery] Re: callback in a plugin Alexandre Plennevaux ha scritto: i would like to add this to the jqUploader plugin, so that i could do something like: function pleaseDoTheseThings (params){ $(#dothis).show(); } $(input#example1).jqUploader({ background: FF9900, barColor: FFDD00, allowedExt: gif, callBack: pleaseDoTheseThings }); Thanks a lot! Alexandre The principle is quite simple. When the plugin has completed its processing, and it is up to the plugin's author to know when it has, you just call your callback function if setted in the options. Something like this: var options = {callback:function(){alert(I've finished!);}} jQuery.fn.my_plugin_with_callback = function(options) { this.each(function(){ ...do some processing }); if(options.callback) callback(); } Renato Ce message Envoi est certifié sans virus connu. Analyse effectuée par AVG. Version: 7.5.467 / Base de données virus: 269.7.0/803 - Date: 13/05/2007 12:17