RE: [jQuery] Browser / AJAX help
This is the function. $(a.bookmarked).click(function(){ var url_id = $(this).attr('href'); var status = $(this).attr('class'); $(this).toggleClass(not); $.ajax({ type: POST, cache:false, url: url_id, }); return false; }); No matter what I try still same thing. Will not work in Chrome or opera...frustrating. Any other ideas? Thanks, Dave -Original Message- From: Andreas Möller [mailto:localhe...@l8m.de] Sent: February-01-10 8:57 AM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Browser / AJAX help Yes its there...just a miss on the copy / paste. No errors reported in FF or IE using firebug / IE developer bar. Like, in the Firebug console? Best regards, Andreas
[jQuery] Browser / AJAX help
I have a star click to bookmark type feature. It works in FF, IE but not Opera or Chrome. Filled star = page book marked Empty star = not bookmarked In FF and IE first click changes the star from empty to filled, click filled star turns back to empty (info saved in db successfully). In Opera and Chrome clicking the stars fills them and 2nd click will return it back to empty but it never saves to the db. If i bookmark 20 pages in FF, go to Chrome or Opera and un-select the bookmarked selections it saves (deletes the bookmark) but it never saves any new bookmarks. My js looks like this: $(a.bookmarked).live('click', function(){ var url_id = $(this).attr('id').split('_'); var status = $(this).attr('class'); $(this).toggleClass(not); $.ajax({ type: POST, cache:false, url: '/bookmark/'+url_id[1], }); return false; }); Any ideas? Dave
RE: [jQuery] Browser / AJAX help
Yes its there...just a miss on the copy / paste. No errors reported in FF or IE using firebug / IE developer bar. Cant find one for chrome. Just weirs how Opera and Chrome wont save a new bookmark yet if there is a bookmark saved fromFF or IE theni go to Chrome or Opera they will remove a bookmark, but wont save one. Dave -Original Message- From: Andreas Möller [mailto:localhe...@l8m.de] Sent: February-01-10 1:39 AM To: jquery-en@googlegroups.com Subject: RE: [jQuery] Browser / AJAX help Have you checked the console to see whether the parameter you pass to your server side script is empty or not? The code you pasted lacks a curly bracket, a closing parenthesis and a semi-colon, but I assume you've got it in your original code, haven't you? Best regards, Andreas
[jQuery] Complicated Question
I have sets of records on a page each has an edit link, clicking the link loads an edit form into the record the user wants to edit, so a user can click edit beside every link creating an unknown number of forms on the page. li id=r_123 user records edit /li li id=r_456 user records edit /li li id=r_789 user records edit /li Each form loaded into the reords li has its own unique id so submitting the form is fine my problem is that its only submitting to the record / form that opens last. So if the user clickes edit, edit , edit for each of the example records above its only submitting to the last record. I know where the problem is, I just don't now how to fix it. When the user clicks edit the js gets the variable from the newly loaded form_id and that gets passed in the uRec(form_id); saying to edit this form so as soon as the user clicks edit again the first form_id is gone and replaced with the newly opened form. Any ideas where I am going wrong here? I cant change the idea to have only 1 form at a time open setup. If I could add a bind sumbit to the script to grab the form_id of what was just submitted then run the function i think that would do the trick. Pretty new at this and not sure where I would go about adding the bind submit. Something like: var form_id = '#?php echo $form_id ?'; $(form_id).bind(submit, uRec(form_id) { return false; } My script onthe page with all the records is : script type=text/javascript var form_id = '#?php echo $form_id ?'; uRec(form_id); /script My external js: function uRec(selector){ var $form = $(selector); $form.submit( function() { var data = $(form_id).serialize(); var form_url = $(form_id).attr('action'); var form_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var update_target = (form_target.replace(_edit, )); $.blockUI({ message: null}); $form.ajaxSubmit({ type: post, url: form_url +'/', data: data, dataType: 'json', success: function(response){ if (response.status === true) { $.unblockUI(); $('#' + update_target).html(response.html).slideToggle('slow').highlightFade({speed: 2000}); $('#' + form_target).slideToggle('slow'); } else { $.unblockUI(); $('#' + form_target).html(response.html); } } }); return false; }); }; Dave
RE: [jQuery] Complicated Question
I have changed my page js to: script type=text/javascript $(form).bind(submit, function() { var form_id = $(this).attr('id'); alert(form_id); uRec(form_id); return false; }) /script The alert shows the form id for the form i am attempting to submit and it changes each time I click sumbit for each form so that's a step closer. But its no longer doing anything with the uRec function. I deleted everything in my uRec function to just alert(form_id); so I should get 2 alerts, one for the click submit and one for it actually hittingthe external js but it never gets there. If I remove the return false; it submits http which is not what I want. Any ideas why the uRec does nothing now? My form submit is a button type = submit. Is that what you were saying to change? Thanks Dave
RE: [jQuery] Complicated Question
I have completely removed the uRec function for now and changed to a regular button, no submit. input type=button value=Button/ /form script type=text/javascript $(button).click(function () { var form_id = '#123123123'; //var form_id = $this.closest('form'); // get the recordId alert(form_id); //uRec(form_id); return false; //or return false; both do nothing }) /script But not even an alert now. Man ohh man Thanks again for your ideas. Dave
RE: [jQuery] Complicated Question
Ok im getting closer. This gives me the id for each form being submitted, the alert(selector); in the external js fires off so its getting the request, but the form now does not submit...just stis there laughing at me. Page js: script type=text/javascript //dummy class added to button to test it out $(.dummy).click(function () { var $this = $(this); var form_id = $this.closest(form).attr(id); // get the form id //alert(form_id); uRec('#'+form_id); //return false; }); /script External js: function uRec(selector){ var $form = $(selector); alert(selector); $form.submit( function() { var data = $(form_id).serialize(); var form_url = $(form_id).attr('action'); var form_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var update_target = (form_target.replace(_edit, )); $.blockUI({ message: null}); $form.ajaxSubmit({ type: post, url: form_url +'/', data: data, dataType: 'json', success: function(response){ if (response.status === true) { $.unblockUI(); $('#' + update_target).html(response.html).slideToggle('slow').highlightFade({speed: 2000}); $('#' + form_target).slideToggle('slow'); } else { $.unblockUI(); $('#' + form_target).html(response.html); } } }); return false; }); };
RE: [jQuery] Complicated Question
Ok so this is where I stand now: Page js: script type=text/javascript //dummy class is my save button , no more submit button $(.dummy).live(click, function () { var $this = $(this); var form_id = $this.closest('form').attr(id); uRec('#' + form_id); }); /script External js: function uRec(selector){ alert(selector); // fires the form id for each form correctly var $form = $(selector); var data = $form.formSerialize(); var form_url = $form.attr('action'); var form_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var update_target = (form_target.replace(_edit, )); alert(form_url + form_target + update_target); return false; }; But the only alert is the selector. alert(form_url + form_target + update_target); never fires off. I think im getting there but still this is all new to me so it more trial and error than anything. Thanks, Dave -Original Message- From: Jack Killpatrick [mailto:j...@ihwy.com] Sent: January-16-10 7:51 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Complicated Question If you're rendering the button on-the-fly (as part of your form) be sure to either a) hook up that button click handler after the button is rendered or b) use the event delegation approach I showed in my example. It sounds like your click is not firing now, probably because the click isn't actually getting bound to the button. - Jack Dave Maharaj :: WidePixels.com wrote: I have completely removed the uRec function for now and changed to a regular button, no submit. input type=button value=Button/ /form script type=text/javascript $(button).click(function () { var form_id = '#123123123'; //var form_id = $this.closest('form'); // get the recordId alert(form_id); //uRec(form_id); return false; //or return false; both do nothing }) /script But not even an alert now. Man ohh man Thanks again for your ideas. Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.139/2620 - Release Date: 01/16/10 04:05:00
RE: [jQuery] Complicated Question - Solved
Ok I got it finally. I managed to get it with bind submit but it was firing off multiple times after each save click so first save would send 1 request, second fired 2 and so onso this is what I ended up with. Page JS: script type=text/javascript $(form).bind(submit, function() { var $this = $(this); var form_id = $this.closest('form').attr(id); uRec('#' + form_id); return false; }); /script Eternal JS: function uRec(selector){ $form.unbind(submit);//prevent repreated submits var data = $(selector).formSerialize(); var form_url = $(selector).attr('action'); var form_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var update_target = (form_target.replace(_edit, )); alert(form_url + form_target + update_target); $.blockUI({ message: null}); $(selector).ajaxSubmit({ type: post, url: form_url +'/', data: data, dataType: 'json', success: function(response){ if (response.status === true) { $.unblockUI(); $('#' + update_target).html(response.html).slideToggle('slow').highlightFade({speed: 2000}); $('#' + form_target).slideToggle('slow'); } else { $.unblockUI(); $('#' + form_target).html(response.html); } } }); return false; }; If anyone could glace over the code to see if there is anything that looks wrong or could use improvement please let me know. Thanks again for all your time Dave -Original Message- From: Jack Killpatrick [mailto:j...@ihwy.com] Sent: January-16-10 7:51 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Complicated Question If you're rendering the button on-the-fly (as part of your form) be sure to either a) hook up that button click handler after the button is rendered or b) use the event delegation approach I showed in my example. It sounds like your click is not firing now, probably because the click isn't actually getting bound to the button. - Jack Dave Maharaj :: WidePixels.com wrote: I have completely removed the uRec function for now and changed to a regular button, no submit. input type=button value=Button/ /form script type=text/javascript $(button).click(function () { var form_id = '#123123123'; //var form_id = $this.closest('form'); // get the recordId alert(form_id); //uRec(form_id); return false; //or return false; both do nothing }) /script But not even an alert now. Man ohh man Thanks again for your ideas. Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.139/2620 - Release Date: 01/16/10 04:05:00
[jQuery] Function help
I have this function: $('#new').live('click', addRecord); function addRecord() { var data = $('#add').serialize(); $.ajax({ type: post, url: /manage/add, data: data, dataType: 'json', success: function(response){ if (response.status === true) { alert(response.status); }); } else { alert(response.status); } } }); } So it works fine but I have this in 5 pages on the site and was wondering how can I turn this into a standard function and call it like: addRecord(form_id); So I only need to place this on the page rather thanthe same script all over the site. Thanks Dave
[jQuery] Disable Submit
I have a form i am submitting via Ajax. So after submit while its waiting for response i have my little spinner so user knows something is happening. But how can i disable the submit while its thinking waiting for a response so the user is not sitting there clicking submit over and over. Using this for my js as of now; $('#new_set').live('click', addRecord); function addRecord() { var data = $('#add').serialize(); $(#add).slideToggle('fast'); $('.flash').prepend('div class=saving/div'); //$('#new_set').die('click'); $.ajax({ type: post, url: /manage/awards/add, data: data, dataType: 'json', success: function(response){ if (response.status === true) { alert(response.status); $('.saving').remove(); } else { //$('#new_set').live('click'); alert(response.status); $('.saving').remove(); } } }); } I tried adding $('#new_set').die('click'); but then it never submitted. Thanks Dave
RE: [jQuery] Re: Disable Submit
Ok thanks.sounds good to me. Will check it out. Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-12-10 4:42 PM To: jQuery (English) Subject: [jQuery] Re: Disable Submit Personally i suggest using BlockUI to overlay the whole form... that way 1) not possible for your user to resubmit 2) gives dead obvious indication something is going on 3) simple as can be to use On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have a form i am submitting via Ajax. So after submit while its waiting for response i have my little spinner so user knows something is happening. But how can i disable the submit while its thinking waiting for a response so the user is not sitting there clicking submit over and over. Using this for my js as of now; $('#new_set').live('click', addRecord); function addRecord() { var data = $('#add').serialize(); $(#add).slideToggle('fast'); $('.flash').prepend('div class=saving/div'); //$('#new_set').die('click'); $.ajax({ type: post, url: /manage/awards/add, data: data, dataType: 'json', success: function(response){ if (response.status === true) { alert(response.status); $('.saving').remove(); } else { //$('#new_set').live('click'); alert(response.status); $('.saving').remove(); } } }); } I tried adding $('#new_set').die('click'); but then it never submitted. Thanks Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10 04:05:00
RE: [jQuery] Re: Disable Submit
Looks good . Thanks will try to add that to my site and see how it goes. Dave -Original Message- From: Scott Sauyet [mailto:scott.sau...@gmail.com] Sent: January-12-10 6:06 PM To: jQuery (English) Subject: [jQuery] Re: Disable Submit On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have a form i am submitting via Ajax. So after submit while its waiting for response i have my little spinner so user knows something is happening. But how can i disable the submit while its thinking waiting for a response so the user is not sitting there clicking submit over and over. MorningZ's suggestion is good, but there is another approach that is always worth considering for any long-running function that you don't want started while it's already running. function myLongRunningFunc() { if (arguments.callee.running) return; arguments.callee.running = true; // your processing here arguments.callee.running = false; } This is simpler than you need, if you have multiple forms to submit, so you'd have to store the running flag in the form, not the function, but it's not too hard to modify. Here's a modification of MorningZ's page: http://jsbin.com/upilo (code http://jsbin.com/upilo/edit) I think this is incomplete, because a form can be submitted in other ways than by the click of a particular button, but some variation of this might do. It's not that I think this is a better solution than blockUI, but it's a useful technique in its own right. Cheers, -- Scott No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10 04:05:00
[jQuery] Append prepend?
I cant seem to understand the logic behind these functions. append prepend appendTo, prependTo I have: div id=sortable *** add new li from response here *** licontent/li licontent/li licontent/li /div so i get my response from the server and trying to get it to appear at the top of all the other li's and slide down with the hi-lighted effect. All i get is above the div id=sortable or under the last li. $('#sortable').append(response.html).slideDown('slow').highlightFade({speed: 3000}); $(response.html).hide().append('#sortable').slideDown('slow').highlightFade( {speed:3000}); Ideas where i went wrong? Dave
RE: [jQuery] Re: Function help
But I think I started off wrong using the click functions the form should be bind submit no? I am here now but nothing addTest('#add_test'); //this is the form ID and on the html page Below is in the external js sheet function addTest(selector) { var $form = $(selector); $form.submit( function() { var form_url = $form.attr('action'); alert(form_url); return false; }); } But no alert. Any ideas? Thanks Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-12-10 3:53 PM To: jQuery (English) Subject: [jQuery] Re: Function help $('#new').live('click', function() { addRecord($(this).closest(form).attr(id)); }); function addRecord(form_id) { .. stuff ... }); No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10 04:05:00
RE: [jQuery] Re: Ajax forms help
Right on...looks easy enough. Is response.html saying to display it as html? I tried making an array to pass as json from php then json_encode it so my arrr was $response = array('status' = true , 'view' = 'all my html code went here') But when I returned my view data from the array it was all slahsed // // / / / like that. -Original Message- From: Ibatex [mailto:mjgris...@gmail.com] Sent: January-11-10 4:35 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help The beauty of json is that you can transfer alot of different data in an organized way. You can very easily send back success/failure status along with the html. success: function(response) { // Response was a success if (response.status) { //update my target div $('#target_div').html(response.html); // Response contains errors } else { // return the form with the errors } On Jan 10, 5:00 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I need some help with a form. I submit the form fine, my problem is depending on the success or failure of the form being saved. I will try to explain as simple as possible form is in its own div form here . div target saved data will appear here/div So what I need is i guess json success true or false response from the form being saved or not then in my success success: function(response) { // Response was a success if (response) { //update my target div // Response contains errors } else { // return the form with the errors } But if I am returning json I cant return my normal html after the successful save, and if I return my response as html there is no way to tell the js what to do. The form or the target is html code How can I tell what the response was (true or false) and return the appropriate html code for the appropriate form or target? Thanks Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/10/10 16:05:00
RE: [jQuery] Re: Ajax forms help
Very detailed response...thank you. I will give it a try and try an alert on different sections of the response and see what happens. I am using firebug to examine the response. Will check the response and repost and say if it its 1 solid line or broke. Thanks...will post shortly. Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: January-11-10 4:36 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Re: Ajax forms help The JSON part of your server response looks fine if you take out the two line breaks - I assume those are just an artifact of posting with Outlook, and your actual JSON response is all on one line. But why does it have the HTML content repeated after the last } that closes the JSON data? You don't want that. Also: Is response.html saying to display it as html? No! response.html says take the object named 'response' and give me its property named 'html'. It has nothing to do with displaying anything or specifying its format. Here, let's take your JSON output and paste it into www.jsonlint.com so it's easier to read: { data: { title: , year_rec: { year: 2010 }, description: , id: 0936d6115e4, profile_id: 4b40eea7-2608-4a3b-9c24-7cb04adcd75b }, status: true, html: pthis is a good test\/p\r\n } You see, it's an object with three properties, named 'data', 'status', and 'html'. The 'data' property is itself an object with properties of its own. So if you have a variable named 'response' (as in Ibatex's example), then you can get to these various properties like so: response.html (the HTML code) response.data.id (the id) response.data.year_rec.year (the year) What you do with those is then up to you, as in Ibatex's earlier example. BTW do you have the Fiddler debugging proxy server and its JSON plugin (and standalone JSON viewer)? For the work you're doing now, you *need* these. http://www.fiddler2.com/ http://www.fiddler2.com/Fiddler2/extensions.asp -Mike On Mon, Jan 11, 2010 at 11:41 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: My response comes back from the server looking like this: (don't think its right to begin with) {data:{title:,year_rec:{year:2010},description:,id:0936d6 115e4,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n}pthis is a good test/p But how would I display only the html section and clean it so its not all slashed and escaped? Thanks Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-11-10 11:44 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help But if I am returning json I cant return my normal html I don't understand why... I pretty much exclusively use JSON back and forth in my jQuery AJAX calls and have a standard JSON object i return: { HasError: boolean, Message: string. Data: object, Count: integer } Many times i'll return HTML on the data property there i think the problem you are having is how you are creating the JSON return string, maybe that's not the right way to do it in PHP ?? (to note, i'm a .NET guy, i don't know what the PHP way is) On Jan 11, 10:06 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Right on...looks easy enough. Is response.html saying to display it as html? I tried making an array to pass as json from php then json_encode it so my arrr was $response = array('status' = true , 'view' = 'all my html code went here') But when I returned my view data from the array it was all slahsed // // / / / like that. -Original Message- From: Ibatex [mailto:mjgris...@gmail.com] Sent: January-11-10 4:35 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help The beauty of json is that you can transfer alot of different data in an organized way. You can very easily send back success/failure status along with the html. success: function(response) { // Response was a success if (response.status) { //update my target div $('#target_div').html(response.html); // Response contains errors } else { // return the form with the errors } On Jan 10, 5:00 pm, Dave Maharaj :: WidePixels.com d
RE: [jQuery] Re: Ajax forms help
Ok so this is my js on the page: $('#test').live('click', test); function test() { var data = $('#add_award').serialize(); $.ajax({ type: post, url: /manage/awards/, data: data, dataType: 'json', success: function(response){ alert(response.data.id); } }); } No alert happens. The response shows up as: {data:{title:,year_rec:{year:2010},description:,id:4cec63 725d2,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n}pthis is a good test/p Not sure why the html code gets repeated after the json part. I am using cake and so far nobody has been able to assit me so im going on trial and error. So to test out the alert response I removed the html part leaving only data and success so I get a Firebug JSON tab in the response: {data:{title:,year_rec:{year:2010},description:,id:4ff9c8 f01b8,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true} And alert(response.data.id); = 4ff9c8f01b8 So its just the darn HTML which is killing me here. Cant figure out how to get just the HTML to apear in the JSON and not display after the code Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: January-11-10 4:36 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Re: Ajax forms help The JSON part of your server response looks fine if you take out the two line breaks - I assume those are just an artifact of posting with Outlook, and your actual JSON response is all on one line. But why does it have the HTML content repeated after the last } that closes the JSON data? You don't want that. Also: Is response.html saying to display it as html? No! response.html says take the object named 'response' and give me its property named 'html'. It has nothing to do with displaying anything or specifying its format. Here, let's take your JSON output and paste it into www.jsonlint.com so it's easier to read: { data: { title: , year_rec: { year: 2010 }, description: , id: 0936d6115e4, profile_id: 4b40eea7-2608-4a3b-9c24-7cb04adcd75b }, status: true, html: pthis is a good test\/p\r\n } You see, it's an object with three properties, named 'data', 'status', and 'html'. The 'data' property is itself an object with properties of its own. So if you have a variable named 'response' (as in Ibatex's example), then you can get to these various properties like so: response.html (the HTML code) response.data.id (the id) response.data.year_rec.year (the year) What you do with those is then up to you, as in Ibatex's earlier example. BTW do you have the Fiddler debugging proxy server and its JSON plugin (and standalone JSON viewer)? For the work you're doing now, you *need* these. http://www.fiddler2.com/ http://www.fiddler2.com/Fiddler2/extensions.asp -Mike On Mon, Jan 11, 2010 at 11:41 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: My response comes back from the server looking like this: (don't think its right to begin with) {data:{title:,year_rec:{year:2010},description:,id:0936d6 115e4,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n}pthis is a good test/p But how would I display only the html section and clean it so its not all slashed and escaped? Thanks Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-11-10 11:44 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help But if I am returning json I cant return my normal html I don't understand why... I pretty much exclusively use JSON back and forth in my jQuery AJAX calls and have a standard JSON object i return: { HasError: boolean, Message: string. Data: object, Count: integer } Many times i'll return HTML on the data property there i think the problem you are having is how you are creating the JSON return string, maybe that's not the right way to do it in PHP ?? (to note, i'm a .NET guy, i don't know what the PHP way is) On Jan 11, 10:06 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Right on...looks easy enough. Is response.html saying to display it as html? I tried making an array to pass as json from php then json_encode it so my arrr was $response = array('status' = true , 'view' = 'all my html code went here') But when I returned my view data from the array it was all slahsed // // / / / like that. -Original Message
RE: [jQuery] Re: Ajax forms help
I am using CakePHP to send the JSONfamiliar with that? if ( $this-RequestHandler-isAjax() ) { Configure::write ( 'debug', 0 ); $this-layout = 'ajax'; $this-autoLayout = false; $this-autoRender = false; $this-data['Award']['id'] = $this-Award-generateKey('11'); $this-data['Award']['profile_id'] = $this-Auth-User('id'); $response['data'] = $this-data['Award']; $response['status'] = true; //$response['html'] = $this-render('dummy'); $this-header('Content-Type: application/json'); echo json_encode($response); return; } From: John Arrowwood [mailto:jarro...@gmail.com] Sent: January-11-10 4:45 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Re: Ajax forms help Your problem looks like it may be on the back-end. Send the code that generates the JSON. On Mon, Jan 11, 2010 at 11:41 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: My response comes back from the server looking like this: (don't think its right to begin with) {data:{title:,year_rec:{year:2010},description:,id:0936d6 115e4,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n}pthis is a good test/p But how would I display only the html section and clean it so its not all slashed and escaped? Thanks Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-11-10 11:44 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help But if I am returning json I cant return my normal html I don't understand why... I pretty much exclusively use JSON back and forth in my jQuery AJAX calls and have a standard JSON object i return: { HasError: boolean, Message: string. Data: object, Count: integer } Many times i'll return HTML on the data property there i think the problem you are having is how you are creating the JSON return string, maybe that's not the right way to do it in PHP ?? (to note, i'm a .NET guy, i don't know what the PHP way is) On Jan 11, 10:06 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Right on...looks easy enough. Is response.html saying to display it as html? I tried making an array to pass as json from php then json_encode it so my arrr was $response = array('status' = true , 'view' = 'all my html code went here') But when I returned my view data from the array it was all slahsed // // / / / like that. -Original Message- From: Ibatex [mailto:mjgris...@gmail.com] Sent: January-11-10 4:35 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help The beauty of json is that you can transfer alot of different data in an organized way. You can very easily send back success/failure status along with the html. success: function(response) { // Response was a success if (response.status) { //update my target div $('#target_div').html(response.html); // Response contains errors } else { // return the form with the errors } On Jan 10, 5:00 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I need some help with a form. I submit the form fine, my problem is depending on the success or failure of the form being saved. I will try to explain as simple as possible form is in its own div form here . div target saved data will appear here/div So what I need is i guess json success true or false response from the form being saved or not then in my success success: function(response) { // Response was a success if (response) { //update my target div // Response contains errors } else { // return the form with the errors } But if I am returning json I cant return my normal html after the successful save, and if I return my response as html there is no way
RE: [jQuery] Re: Ajax forms help
Sorry for the number of back to back posts...just making progress somewhat. OK! I got it part ways no more html after the JSON. {data:{title:,year_rec:{year:2010},description:,id:6186d5 5b8f0,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n} Now to display the HTML but without all the \/p\r\n Dave From: John Arrowwood [mailto:jarro...@gmail.com] Sent: January-11-10 4:45 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Re: Ajax forms help Your problem looks like it may be on the back-end. Send the code that generates the JSON. On Mon, Jan 11, 2010 at 11:41 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: My response comes back from the server looking like this: (don't think its right to begin with) {data:{title:,year_rec:{year:2010},description:,id:0936d6 115e4,profile_id:4b40eea7-2608-4a3b-9c24-7cb04adcd75b},status:true,h tml:pthis is a good test\/p\r\n}pthis is a good test/p But how would I display only the html section and clean it so its not all slashed and escaped? Thanks Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-11-10 11:44 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help But if I am returning json I cant return my normal html I don't understand why... I pretty much exclusively use JSON back and forth in my jQuery AJAX calls and have a standard JSON object i return: { HasError: boolean, Message: string. Data: object, Count: integer } Many times i'll return HTML on the data property there i think the problem you are having is how you are creating the JSON return string, maybe that's not the right way to do it in PHP ?? (to note, i'm a .NET guy, i don't know what the PHP way is) On Jan 11, 10:06 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Right on...looks easy enough. Is response.html saying to display it as html? I tried making an array to pass as json from php then json_encode it so my arrr was $response = array('status' = true , 'view' = 'all my html code went here') But when I returned my view data from the array it was all slahsed // // / / / like that. -Original Message- From: Ibatex [mailto:mjgris...@gmail.com] Sent: January-11-10 4:35 AM To: jQuery (English) Subject: [jQuery] Re: Ajax forms help The beauty of json is that you can transfer alot of different data in an organized way. You can very easily send back success/failure status along with the html. success: function(response) { // Response was a success if (response.status) { //update my target div $('#target_div').html(response.html); // Response contains errors } else { // return the form with the errors } On Jan 10, 5:00 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I need some help with a form. I submit the form fine, my problem is depending on the success or failure of the form being saved. I will try to explain as simple as possible form is in its own div form here . div target saved data will appear here/div So what I need is i guess json success true or false response from the form being saved or not then in my success success: function(response) { // Response was a success if (response) { //update my target div // Response contains errors } else { // return the form with the errors } But if I am returning json I cant return my normal html after the successful save, and if I return my response as html there is no way to tell the js what to do. The form or the target is html code How can I tell what the response was (true or false) and return the appropriate html code for the appropriate form or target? Thanks
[jQuery] Fade question
When i add a new record its inserted into a div. How can I make it so its has a color then fades out. Kind of like a success message after you save something only i am just fading out the color not the content. jquery UI highlight is a good example of the idea i am looking for. So I have my: $(response.html).hide().prependTo('#sortable').slideDown('slow'); so i would like it to be yellow for example when the user first sees the new record then slowly fade out leaving only the record. Thanks Dave
RE: [jQuery] Re: Fade question
Right on thanks... I looked around but noting simple so I will def check it out. Thanks. Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: January-11-10 7:30 PM To: jQuery (English) Subject: [jQuery] Re: Fade question I used the color plugin for exactly that... works really well http://plugins.jquery.com/project/color http://dev.jquery.com/~john/ticket/fx-rewrite2/ On Jan 11, 5:35 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: When i add a new record its inserted into a div. How can I make it so its has a color then fades out. Kind of like a success message after you save something only i am just fading out the color not the content. jquery UI highlight is a good example of the idea i am looking for. So I have my: $(response.html).hide().prependTo('#sortable').slideDown('slow'); so i would like it to be yellow for example when the user first sees the new record then slowly fade out leaving only the record. Thanks Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/11/10 16:05:00
[jQuery] Ajax forms help
I need some help with a form. I submit the form fine, my problem is depending on the success or failure of the form being saved. I will try to explain as simple as possible form is in its own div form here . div target saved data will appear here/div So what I need is i guess json success true or false response from the form being saved or not then in my success success: function(response) { // Response was a success if (response) { //update my target div // Response contains errors } else { // return the form with the errors } But if I am returning json I cant return my normal html after the successful save, and if I return my response as html there is no way to tell the js what to do. The form or the target is html code How can I tell what the response was (true or false) and return the appropriate html code for the appropriate form or target? Thanks Dave
RE: [jQuery] Re: Styling dynamic content
What about $(.file).live('click', function(){ alert(this) }); I load elements dynamically into a page after the original load and can access their events. For example I have a add new record button, loads a form saves to the database and updates the current page with the new record. The new record has edit and delete which are now new to the page as they were not there when the page originally loaded. If I click them sure enough my edit form loads or the entry gets deleted. Maybe Imis-understod what your trying to do. Dave -Original Message- From: Jason Kaczmarsky [mailto:jkaczmar...@yahoo.com] Sent: December-18-09 1:54 AM To: jQuery (English) Subject: [jQuery] Re: Styling dynamic content Ahah, this was the problem I thought i was having. I can't make jQuery work on dynamic content. If an element with a class of file is added to the document, like the previous case, no jQuery event related to that element works. Ex: $(.file).click(function(){ alert(this) }); Nothing is ever alerted if that element is clicked. Example page: http://pendarenstudios.com/NEW/file_sel.php On Dec 17, 10:39 am, Jason Kaczmarsky jkaczmar...@yahoo.com wrote: I must have missed something cause I made a new page and rewrote the code and it worked fine. Thanks for the help guys. On Dec 17, 5:26 am, Richard D. Worth rdwo...@gmail.com wrote: Works for me: http://jsbin.com/egoto/ - Richard On Wed, Dec 16, 2009 at 8:44 PM, Jason Kaczmarsky jkaczmar...@yahoo.comwrote: Yes, I am sure they are the correct class and are showing up properly. Button press: //loop $(#files).append('div class=file'+Files[i]+'/div'); //end loop Firebug: div id=files style=display: block; div class=filework.txt/div div class=fileSAS Guide.txt/div /div On Dec 16, 7:43 pm, Smith, Allex allex.sm...@chelanpud.org wrote: The browser should render all the styles no matter when they enter. Are you sure that the class is assigned to those elements? I would make sure by peeking at the rendered html via Firebug. -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Jason Kaczmarsky Sent: Wednesday, December 16, 2009 2:14 PM To: jQuery (English) Subject: [jQuery] Styling dynamic content So I've created a little app which loads some filenames into a div via an AJAX query. This happens when a user clicks a button, not when the page loads. Because of this, I cannot style the filenames how I want. I've tried using CSS to do the trick: .file{ color: #F00; } .file:hover{ cursor:pointer; color:#000; } This CSS colors the filenames red when it loads, but nothing in the hover event works. Instead of this, I tried using jQuery to style it. $(.file).hover(function(){ $(this).css(background-color,#F00); },function(){ $(this).css(background-color,#000); }); This also does not change anything. I assume it is because the element does not exist when the page is rendered, but later on. Although this doesn't explain why the text is red when I use the CSS, so I'm a bit confused. How would I accomplish this? No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.716 / Virus Database: 270.14.102/2556 - Release Date: 12/17/09 05:00:00
[jQuery] Doing something wrong
I have this function for an ajax edit form. script type=text/javascript $(document).ready( function() { var form_id = '#?php echo $form_id ?'; $(form_id).bind('submit',function() { var form_url = $(form_id).attr('action'); var page_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var update_target = (page_target.replace(_edit, )); var queryString = $(form_id).formSerialize(); $(this).ajaxSubmit({ type:'post', url: form_url, data: queryString, target: '#' + update_target, success: function(response, status) { // Response was a success if (response.success === true) { $('#' + update_target).slideToggle('slow'); $('#' + page_target).html(response).slideToggle('slow'); // Response contains errors } else { $('#'+update_target).html(response); } } }); return false; }); }); /script So if the form if saved will update the content (update_target ) and hide the form (page_target ) after save or if not saved will simply return the form with errors needing correction. The functionality of the save / not saved works but the success in the ajaxSubmit is getting lost. The $('#' + update_target).slideToggle('slow'); $('#' + page_target).html(response).slideToggle('slow'); or $('#'+update_target).html(response); does nothing. No slide no nothing...just sits there I tried alert(response); for both success and fail of the save and the html data shows up so u until that point everything is working. Just my var page_target and var update_target seem to vanish in the success. Any ideas where I went wrong or how to fix this? Thanks Dave
RE: [jQuery] get random record?
Sorry I should have explained it better. My php will get the record. I just need help using jquery to get the record every (set time, 60 seconds 120 seconds or when the user clicks next) Basically I want to add a side module to the page which has recent posts with a avatar of the person who made the post and a brief dscription of the post and a link to the post. This will change every (set time automaticaly or if the user clicks next it will pull another random record) I just need some help with the function to request a new record via ajax every xxx time or when user clicks next. I can pull a random record no problem with $ajax and load it into my area I need, just telling the script to get a new record duration is where im stuck. Sorry and thanks, Dave -Original Message- From: brian [mailto:zijn.digi...@gmail.com] Sent: December-01-09 2:45 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] get random record? On Tue, Dec 1, 2009 at 4:33 AM, Michel Belleville michel.bellevi...@gmail.com wrote: If I were you I wouldn't let JavaScript do the randomizing, I would do it server-side instead, providing a request that returns a random record and pinging it with a simple AJAX query ; this way, JavaScript doesn't need to be aware of what you want to send and it doesn't select the id client-side (without the database nearby). I agree with Michel. Keep the javascript a simple request with no params and let the server script (or even the DB) do the randomising. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.709 / Virus Database: 270.14.83/2526 - Release Date: 12/01/09 04:29:00
[jQuery] get random record?
Has anyone come across a simple function that will get a random record from the db? I just need to send a request every min or so to get new content from the db and change the content. Pretty much like a banner rotator but used for random content. thanks, Dave
[jQuery] Selector Help
How would I go about adding class to the li in this set up? lia href=# class=filterspanall/span/a/li lia href=# class=filterspansome/span/a/li lia href=# class=filterspannone/span/a/li $('a.filter').click(function(){ $(???).addClass('active'); }); Thanks Dave
[jQuery] Validation Question
I submit my form , check valid, valid then away it goes. I was wondering 1 thing. I have $(this).validate(validate_awards); var valid = $(this).valid(); if (valid) { do my stuff } Now I have validate_awards which contains my rules for validation var validate_awards = { keyup: true, rules: { data[Award][title]:{required:true}, data[Award][description]:{required:true,minlength: 25}, data[Award][year]:{required:true} } }; On another form same set up but validate_user is called to validate the user. Can I just group all of my validation rules into 1 var such as var validations = { keyup: true, rules: { data[Award][title]:{required:true}, data[Award][description]:{required:true,minlength: 25}, data[Award][year]:{required:true} data[User][fname]:{required:true}, data[User][lname]:{required:true}, data[User][age]:{required:true} } }; and jquery will ignore any fields that are not present in the form being validated? Or when I validate my awards it will look for the User fields since its included in the validations rules? Thanks Dave
[jQuery] Create a function?
I have the exact same code on every page where a form gets submitted. How can i turn that into a simple function? The only thing that changes is the $(this).validate(validate_awards) and the form ID; It would be so much easier if the function was in one place and called where needed but I cant figure this out. Something like: $('#newAward').submit(function({ myFormFunction(validate_awards, '#newAward'); }); where I could put in the formID and the validation rules to use CURRENTLY HAVE THIS ON EVERY PAGE: Only the validate_awards and #newAward changes $('#newAward').submit(function() { $(this).validate(validate_awards); var valid = $(this).valid(); if (valid) { var form_url = $(this).attr('action'); var page_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var queryString = $('#newAward').formSerialize(); $(this).ajaxSubmit({ type:'post', url: form_url+'/', data: queryString, resetForm: true, success:function(response){ alert(response); $('#'+page_target).slideToggle('slow', function (){ $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); Any help would be greatly appreciated. Thanks, Dave
RE: [jQuery] Create a function?
Thank you very much. I will try it out. Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: November-24-09 10:02 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Create a function? Your code could end up looking something like this: function setValidation( selector, validator ) { $(document).ready( function() { var $form = $(selector); $form.submit( function() { $form.validate( validator ); var valid = $(this).valid(); if( valid ) { var form_url = $form.attr('action'); var page_target = form_url.substr(1).replace(new RegExp(/, g), _); var queryString = $form.formSerialize(); $form.ajaxSubmit({ type: 'post', url: form_url + '/', data: queryString, resetForm: true, success: function( response ) { alert( response ); $( '#' + page_target ).slideToggle('slow', function() { $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); }); } And for the case you listed, you would call it like this: setValidation( '#newAward', validate_awards ); I threw a $(document).ready() block into that code. You don't need that if your call to the setValidation() function is already inside a document ready callback, but it doesn't do any harm either. -Mike On Tue, Nov 24, 2009 at 3:48 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have the exact same code on every page where a form gets submitted. How can i turn that into a simple function? The only thing that changes is the $(this).validate(validate_awards) and the form ID; It would be so much easier if the function was in one place and called where needed but I cant figure this out. Something like: $('#newAward').submit(function({ myFormFunction(validate_awards, '#newAward'); }); where I could put in the formID and the validation rules to use CURRENTLY HAVE THIS ON EVERY PAGE: Only the validate_awards and #newAward changes $('#newAward').submit(function() { $(this).validate(validate_awards); var valid = $(this).valid(); if (valid) { var form_url = $(this).attr('action'); var page_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var queryString = $('#newAward').formSerialize(); $(this).ajaxSubmit({ type:'post', url: form_url+'/', data: queryString, resetForm: true, success:function(response){ alert(response); $('#'+page_target).slideToggle('slow', function (){ $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); Any help would be greatly appreciated. Thanks, Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.709 / Virus Database: 270.14.76/2519 - Release Date: 11/24/09 04:16:00
RE: [jQuery] Create a function?
Sorry. I cant seem to get it to go. Maybe I did not clearly explain the problem. I want to put the function like you have below in my external js, then on my html pages that have a form just set it up so all I have to do is include the setValidation( '#newAward', validate_awards ); on those pages so 1 function gets called for every form. I put your function setValidation( selector, validator ) { } In my external js On the page with a form I put script type=text/javascript $(document).ready( function() { setValidation( '#newAward', validate_awards ); }); /script But when I load the page I get: setValidation is not defined Ideas where I screwed up? Thanks again. Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: November-24-09 10:02 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Create a function? Your code could end up looking something like this: function setValidation( selector, validator ) { $(document).ready( function() { var $form = $(selector); $form.submit( function() { $form.validate( validator ); var valid = $(this).valid(); if( valid ) { var form_url = $form.attr('action'); var page_target = form_url.substr(1).replace(new RegExp(/, g), _); var queryString = $form.formSerialize(); $form.ajaxSubmit({ type: 'post', url: form_url + '/', data: queryString, resetForm: true, success: function( response ) { alert( response ); $( '#' + page_target ).slideToggle('slow', function() { $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); }); } And for the case you listed, you would call it like this: setValidation( '#newAward', validate_awards ); I threw a $(document).ready() block into that code. You don't need that if your call to the setValidation() function is already inside a document ready callback, but it doesn't do any harm either. -Mike On Tue, Nov 24, 2009 at 3:48 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have the exact same code on every page where a form gets submitted. How can i turn that into a simple function? The only thing that changes is the $(this).validate(validate_awards) and the form ID; It would be so much easier if the function was in one place and called where needed but I cant figure this out. Something like: $('#newAward').submit(function({ myFormFunction(validate_awards, '#newAward'); }); where I could put in the formID and the validation rules to use CURRENTLY HAVE THIS ON EVERY PAGE: Only the validate_awards and #newAward changes $('#newAward').submit(function() { $(this).validate(validate_awards); var valid = $(this).valid(); if (valid) { var form_url = $(this).attr('action'); var page_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var queryString = $('#newAward').formSerialize(); $(this).ajaxSubmit({ type:'post', url: form_url+'/', data: queryString, resetForm: true, success:function(response){ alert(response); $('#'+page_target).slideToggle('slow', function (){ $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); Any help would be greatly appreciated. Thanks, Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.709 / Virus Database: 270.14.76/2519 - Release Date: 11/24/09 04:16:00
RE: [jQuery] Create a function?
Sorry its only local right now so I will try to add as much as I can here. Page with a form has: link rel=stylesheet type=text/css href=/css/styles.css / link rel=stylesheet type=text/css href=/css/typography.css / script type=text/javascript src=/js/jquery.js/script script type=text/javascript src=/js/jquery.form.js/script script type=text/javascript src=/js/jquery.validate.js/script script type=text/javascript src=/js/site.js/script Normal html code with my #newAward form, then at the bottom of the page script type=text/javascript $(document).ready( function() { setValidation('#newAward', validate_awards); }); /script site.js has just the one function you provided function setValidation( selector, validator ) { $(document).ready( function() { var $form = $(selector); $form.submit( function() { $form.validate( validator ); var valid = $(this).valid(); if( valid ) { var form_url = $form.attr('action'); var page_target = form_url.substr(1).replace(new RegExp(/, g), _); var queryString = $form.formSerialize(); $form.ajaxSubmit({ type: 'post', url: form_url + '/', data: queryString, resetForm: true, success: function( response ) { alert( response ); $( '#' + page_target ).slideToggle('slow', function() { $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); }); } I checked with firebug that all the scripts do infact load. Thanks again, Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: November-24-09 11:44 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Create a function? Do you have a script tag to load your external .js file? Post a link to a test page and I can tell you for sure what's wrong. -Mike On Tue, Nov 24, 2009 at 6:33 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Sorry. I cant seem to get it to go. Maybe I did not clearly explain the problem. I want to put the function like you have below in my external js, then on my html pages that have a form just set it up so all I have to do is include the setValidation( '#newAward', validate_awards ); on those pages so 1 function gets called for every form. I put your function setValidation( selector, validator ) { } In my external js On the page with a form I put script type=text/javascript $(document).ready( function() { setValidation( '#newAward', validate_awards ); }); /script But when I load the page I get: setValidation is not defined Ideas where I screwed up? Thanks again. Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: November-24-09 10:02 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Create a function? Your code could end up looking something like this: function setValidation( selector, validator ) { $(document).ready( function() { var $form = $(selector); $form.submit( function() { $form.validate( validator ); var valid = $(this).valid(); if( valid ) { var form_url = $form.attr('action'); var page_target = form_url.substr(1).replace(new RegExp(/, g), _); var queryString = $form.formSerialize(); $form.ajaxSubmit({ type: 'post', url: form_url + '/', data: queryString, resetForm: true, success: function( response ) { alert( response ); $( '#' + page_target ).slideToggle('slow', function() { $(response).hide().prependTo('#sortable').slideDown('slow'); }); } }); } return false; }); }); } And for the case you listed, you would call it like this: setValidation( '#newAward', validate_awards ); I threw a $(document).ready() block
RE: [jQuery] slideToggle lag in Firefox
I have the same problem. Firefox eats up a lot of memory when open for a long time (900k sometimes) and my toggle divs drag ass. If I find a solution I would be happy to hear. Thanks, Dave -Original Message- From: Jason Kaczmarsky [mailto:jkaczmar...@yahoo.com] Sent: November-23-09 10:06 PM To: jQuery (English) Subject: [jQuery] slideToggle lag in Firefox So I have a div with an input, textarea, and submit button. A link makes it so you can expand/contract this div. In Firefox only, the div resize is very laggy and its clearly shown on the site. That happens when you open it. The rest of the site is pushed down like its supposed to, but the elements being moved seem to duplicate, like FF is not rending things fast enough. The above image is the bottom of the site, appearing multiple times when it should once appear once. I read somewhere that Firebug causes things to be slower, and I do have Firebug installed, but I tested it on another computer without Firebug and the same thing happens. It works much smoother in any other browser. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.709 / Virus Database: 270.14.76/2519 - Release Date: 11/23/09 04:22:00
[jQuery] Best Practise Question
I have the following set up: When you click edit and the #manage_award toggles out and the #manage_award_edit toggles in giving and overlapping effect. On every browser it looks fine but in FF if I have the browser open for a while the memory FF uses gets up to 800k or more and the toggle looks jittery or stalls thru the effect. I am wondering if there is anything I should not toggle? Size? Height of the toggle? Right now I am toggling out straight html and toggle in a mini form with 3 fields, no images and pretty basic css. If there is anything in the script itself that could be cleaned or improved? Any ideas or insight would be great. Thanks div id=manage_award dl dtTitle/dt ddSomething here/dd dda href=/manage/award class=requestEdit/a/dd /dl /div div id=manage_award_edit class=hidden/div $(a.request).live('click', function (){ var url_id = $(this).attr(href); var request_id = url_id.substr(1).replace( new RegExp( / ,g), _ ); var set_id = (request_id.replace(_edit, )); $('#' + set_id).append('div class=loading/div'); $('.loading').fadeIn('normal'); if( $('#' + request_id).hasClass(loaded)) { $('.loading').slideUp('normal').remove(); $('#' + set_id).slideToggle('slow').toggleClass(hidden); $('#' + request_id).slideToggle('slow'); } else { $.ajax({ type: GET, url: url_id, cache: true, success: function(data){ $('.loading').slideUp('normal').remove(); $('#' + set_id).slideToggle('slow').toggleClass(hidden); $('#' + request_id).html(data).slideToggle('slow').addClass('loaded'); } }); } return false; }); Dave
[jQuery] Remote Validation
Does anyone know how to add the spinner to the field that's being checked remote? I have the validation and the rules working. I just cant seem to see how to add the little gif to let the user know something is happening while it checking. script type=text/JavaScript $(document).ready(function(){ $('#RegistrationRegisterForm').bind('submit', function() { $(this).validate(validate_registration); var form_url = $(this).attr('action'); var valid = $(this).valid(); if (valid) { var queryString = $('#RegistrationRegisterForm').formSerialize(); $(this).ajaxSubmit({ //beforeSubmit: validate, type:'post', url: form_url, data: queryString, //target: '#domains', //success: function(){ // $(.success).show().fadeOut(5000).slideUp(); // } }); } return false; }); }); /script Dave
[jQuery] Pagination with History
Has anyone come across a nice pagination script for server side processing that has a built in history feature so if a user clicks on a link in the pagination then hits back in the browser it will take you back to your pagination set, not back to page 1. Thanks, Dave
[jQuery] IE Help - Code Included
I have a my content wrapped in a div. It has a delete' button. Click delete will add the pre_delete class to the div your about to delete and a confirm alert. Click yes and the section fades out / deleted in back-end. Click no the div returns to normal with the pre_delete class being removed. In IE 7 (not tested in IE6, fine in FF, Google, Opera) if i click delete / confirm yes the div does not fade out. when i hit refresh the record has been deleted, its just not performing the fadeout / remove after confirm. Looking at thisany ideas? $(a.delete).live('click', function (){ var url_id = $(this).attr(href); var div_id = url_id.split('/'); var set_id = 'set_'+div_id[div_id.length-1]; $('#'+set_id).addClass('pre_delete'); if (confirm('Are you sure you want to delete the selected entry?')) { $.ajax({ type: POST, url: url_id, success: function(){ $('#' + set_id).fadeOut('fast').slideUp('slow', function () { $(this).remove(); }); } }); } else { $('#'+set_id).removeClass('pre_delete'); } return false; }); Thanks, Dave
RE: [jQuery] IE Help - Code Included
Sounds good. Will give it a try and mess around with it more. Thanks. Dave _ From: Michel Belleville [mailto:michel.bellevi...@gmail.com] Sent: November-11-09 7:34 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] IE Help - Code Included I'm not sure what it is but it's obviously in the ajax callback (the delete completed). My best guess would be that chaining fadeOut() and slideUp() this way may not be a very good idea, better to use just one or the other in my opinion, though I'm not sure it's what's causing the trouble. Anyway, IE is always a pain, so... Michel Belleville 2009/11/11 Dave Maharaj :: WidePixels.com d...@widepixels.com I have a my content wrapped in a div. It has a delete' button. Click delete will add the pre_delete class to the div your about to delete and a confirm alert. Click yes and the section fades out / deleted in back-end. Click no the div returns to normal with the pre_delete class being removed. In IE 7 (not tested in IE6, fine in FF, Google, Opera) if i click delete / confirm yes the div does not fade out. when i hit refresh the record has been deleted, its just not performing the fadeout / remove after confirm. Looking at thisany ideas? $(a.delete).live('click', function (){ var url_id = $(this).attr(href); var div_id = url_id.split('/'); var set_id = 'set_'+div_id[div_id.length-1]; $('#'+set_id).addClass('pre_delete'); if (confirm('Are you sure you want to delete the selected entry?')) { $.ajax({ type: POST, url: url_id, success: function(){ $('#' + set_id).fadeOut('fast').slideUp('slow', function () { $(this).remove(); }); } }); } else { $('#'+set_id).removeClass('pre_delete'); } return false; }); Thanks, Dave No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.704 / Virus Database: 270.14.60/2496 - Release Date: 11/11/09 16:11:00
[jQuery] Submit Function Code Help
I have the same code one multiple pages and would like to clean that up. It is for submitting a form via Ajax. The only thing different in the form would be the form id , where its going and the validation rules. But all of that is taken care of thru standard naming convections thru-out the site. I have on the page with the form: $(document).ready( function() { $('#newEntry').bind('submit', function(testForm)); }); In the external js: function testForm() { var form_id = this.attr('id'); var form_url = $(this).attr('action'); var page_target = form_url.substr(1).replace( new RegExp( / ,g), _ ); var hide_form = page_target + '_form'; alert(form_id); alert(form_url); alert(page_target); alert(hide_form); return false; } Can someone see where I am going wrong here so far? No alerts or anthing. Thanks Dave
[jQuery] Show Loading
Is there a way that when your loading content to display the loading div for a minimum amount of time? I am requesting Ajax grab some content for me and while its doing so I show the loading spinner but in some cases it just flashes for a millisecond and gone. Can it be set to show for a minimum length of time? $(a.add).click(function (){ var url_id = $(this).attr(href); var div_id = url_id.substr(1).replace( new RegExp( / ,g), _ ); $('#' + div_id).after('div class=loading/div'); $('.loading').fadeIn('normal'); $.ajax({ type: GET, url: url_id, cache: true, success: function(response){ $('.loading').fadeOut('normal').remove(); $('#' + div_id).html(response).slideToggle('slow'); } }); return false; }); Thanks Dave
[jQuery] Sortable Help
I am trying to send the data in a numbered array but i end up with set[]=56454set[]=54546522 when i need set[0]=56454set[1]=54546522 $(document).ready(function() { $(#sortable).sortable({ placeholder: 'ui-state-highlight', update: function() {$.post('/order/.php',{data: $(#sortable).sortable('toArray')});} }); $(#sortable).disableSelection(); }); Can someone seewhere I am going wrong here? Thanks Dave
[jQuery] Confirm Delete
I am attempting to add a class to a div before deleting it. I just cant get the class to remove if the user selects no. Anyone have tips or a link with suggestions? I found the jquery.confirm.js script but unable to add a class to the element being deleted before confirm Thanks Dave
RE: [jQuery] Confirm Delete
My bad. Here is what I have so far. $(a.delete).live('click', function (){ var url_id = $(this).attr(href); var div_id = url_id.split('/'); var set_id = 'set_'+div_id[div_id.length-1]; $('#'+set_id).addClass('pre_delete'); $.ajax({ type: POST, url: url_id, success: function(){ $('#' + set_id).fadeOut('slow', function () { $(this).remove(); }); } }); return false; }); I need to add in the confirm message. Above just adds the class when delete is clicked then deletes it. I would like the click delete add the class to the div then the confirm message appears. If they select yes then delete goes thru, if selected no then the added class gets removed. Thanks again Dave From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-09-09 1:32 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Confirm Delete On Mon, Nov 9, 2009 at 8:58 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am attempting to add a class to a div before deleting it. I just cant get the class to remove if the user selects no. Anyone have tips or a link with suggestions? I found the jquery.confirm.js script but unable to add a class to the element being deleted before confirm Hard to give guidance without seeing what code you are using now. Also, in your first paragraph you say I just cant get the class to remove. In your second paragraph, you say you are unable to add a class. So not sure which it is. Either way, $('#myDiv').addClass('className'); or $('#myDiv').removeClass('className') should be all you need. If those aren't working out, seeing some code would go a long way towards helping to troubleshoot. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
RE: [jQuery] Re: Confirm Delete
Right on. Thanks you. Dave -Original Message- From: MorningZ [mailto:morni...@gmail.com] Sent: November-09-09 2:25 PM To: jQuery (English) Subject: [jQuery] Re: Confirm Delete $(a.delete).live('click', function (){ var url_id = $(this).attr(href); var div_id = url_id.split('/'); var set_id = 'set_'+div_id[div_id.length-1]; $('#'+set_id).addClass('pre_delete'); if (confirm('Delete?')) { $.ajax({ type: POST, url: url_id, success: function(){ $('#' + set_id).fadeOut('slow', function () { $(this).remove(); }); } }); } else { $('#'+set_id).removeClass('pre_delete'); } return false; }); On Nov 9, 12:15 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: My bad. Here is what I have so far. $(a.delete).live('click', function (){ var url_id = $(this).attr(href); var div_id = url_id.split('/'); var set_id = 'set_'+div_id[div_id.length-1]; $('#'+set_id).addClass('pre_delete'); $.ajax({ type: POST, url: url_id, success: function(){ $('#' + set_id).fadeOut('slow', function () { $(this).remove(); }); } }); return false; }); I need to add in the confirm message. Above just adds the class when delete is clicked then deletes it. I would like the click delete add the class to the div then the confirm message appears. If they select yes then delete goes thru, if selected no then the added class gets removed. Thanks again Dave From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-09-09 1:32 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Confirm Delete On Mon, Nov 9, 2009 at 8:58 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am attempting to add a class to a div before deleting it. I just cant get the class to remove if the user selects no. Anyone have tips or a link with suggestions? I found the jquery.confirm.js script but unable to add a class to the element being deleted before confirm Hard to give guidance without seeing what code you are using now. Also, in your first paragraph you say I just cant get the class to remove. In your second paragraph, you say you are unable to add a class. So not sure which it is. Either way, $('#myDiv').addClass('className'); or $('#myDiv').removeClass('className') should be all you need. If those aren't working out, seeing some code would go a long way towards helping to troubleshoot. -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Validation Remote Question
Can you set required as remote? For example I have a year field where the server validates the rules, 4 numeric characters, required. But rather then having to put the rules for every field in the js required: true, number: true, maxlength 4, minlength:4 that are duplicates the the server validation I was hoping there was away to simply use remote for the fields. I tried using just remote but user enter abc into the year field its valid when I submit the form, then the server says no its not valid after the form is submitted. At this point the user has been directed with a successful save message even though nothing saved. So basically is there a way to set it up so every field I need checked is set to required but it checks the server for the actual validation rules? Thanks, Dave
[jQuery] Characters in a string
I have a string where i need to get the last specific number of characters but cant seem to find an answer when you don't know the length of the strings since its dynamic. var str=/folder/subfolder/setfolder/6ab0e34e915; where i need the last 11 digits (6ab0e34e915). The folder names change so that number is never know to subtrct back from leaving me with 11 Any help would be great. Thanks Dave
RE: [jQuery] Characters in a string
Thanks. that's just what I needed. Dave _ From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-08-09 3:32 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Characters in a string On Sun, Nov 8, 2009 at 10:53 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have a string where i need to get the last specific number of characters but cant seem to find an answer when you don't know the length of the strings since its dynamic. var str=/folder/subfolder/setfolder/6ab0e34e915; where i need the last 11 digits (6ab0e34e915). The folder names change so that number is never know to subtrct back from leaving me with 11 straight JS. var str = /folder/subfolder/setfolder/6ab0e34e915; var arr = str.split('/'); // converts your string to an array, delimited by the '/' character var myNumber = arr[arr.length-1]; -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Append Help
I have a div that I want to add new content to after the div closes div id=originaloriginal content here /div div id=something_new new content here /div So the new content I am adding gets inserted after the original div. I tried: $(response).fadeIn('slow').appendTo('#original'); $(response).fadeIn('slow').append('#original'); $(response).fadeIn('slow').prependTo('#original'); $(response).fadeIn('slow').after('#original'); But its always ending up inside div id=originaloriginal content here div id=something_newnew content here/div /div What am I doing wrong here? Thanks Dave
[jQuery] Ajax submit help
I am sending a form via Ajax and have that part working fine. Now my issue is if I use validate before sending I have to write the exact validation rues that are done on the server...not the best solution coding the same thing twice. And some of my validation rules require checking the database for existing emails and other fields like that it gets a lot more complicated with remote and all that scripting. My problem is (will try to explain so it makes sense) I click edit button on a page and a this does an Ajax requests to load a form into a div allowing the user to make their edits, save then removes the form and shows the updated content or cancel jut removes the form. What I would like to do is skip validating the form with js all together, but when it is submitted it just sits there until it gets a response from the server saying ok its all valid and saved then remove the form and do the toggle slide fades and jazzy stuffif not saved then the errors reported by the server show up. I have currently: $(form_id).bind('submit', function() { //$(this).validate(validate_domain); // var valid = $(this).valid(); // if (valid) { var queryString = $(form_id).formSerialize(); $(this).ajaxSubmit({ //beforeSubmit: validate, type:'post', url: form_url', data: queryString, target: '#' + update_target, success: function(){ $('#' + update_target).slideToggle('slow'); $('#' + page_target).slideToggle('slow', function () { $(.success).show().fadeOut(5000).slideUp(); }); } }); //} return false; }); I was thinking something like (im new at this so try not to laugh if im way off) $(this).ajaxSubmit({ //beforeSubmit: validate, type:'post', url: form_url', data: queryString, target: '#' + update_target, success: valid_response if (if valid_response) == valid) { //valid so do whatever I need to do $('#' + update_target).slideToggle('slow'); $('#' + page_target).slideToggle('slow', function () { $(.success).show().fadeOut(5000).slideUp(); }); }else { //do nothing, server will show errors on the form } Function validResponse(response){ var valid = false; if (response = valid){ valid = true; } return valid; } Any help would be appreicated. Thanks Dave
[jQuery] Remove Error Message
Well i finally got the remote validation working. But if there is an error in a form then i correct it the error message still shows. How can I remove the message once the error is fixed? I am testing a email address in a db with 2 emails so i know if its unique or not. rules: { data[Profile][email]:{required: true,email:true, remote: {url: /manage/profile/validate,type: post, data: {fieldname: 'email'}}} }, messages: { 'data[Profile][email]': { required: '* This is from JS required', email: '* This is from JS email', remote: '* This is from JS remote'} } Thanks Dave
[jQuery] Toggle Help
I am loading a page using $Ajax and upon success i run a toggle function. Now how can i set it up so that once its been loaded it will not make a second Ajax request? Basically a user clicks edit and i get the form via Ajax request and place it into a div. Once completed the original content toggles to the newly loaded form. If a user clicks cancel the form toggles revealing the original content. But if they click edit again it runs the request to get the form. But since its already been loaded and now just hidden in the div so i do not need to make the Ajax request call again $(a#mod_test).click(function(){ $('#test').after('div class=loading/div'); $('.loading').fadeIn('normal'); $.ajax({ type: POST, url: '/manage/account/edit', cache: true, success: function(data){ $('.loading').fadeOut('normal').remove(); $(#test).slideToggle('slow').toggleClass(hidden); $(#testForm).html(data).slideToggle('slow'); } }); return false; }); How can I set a variable in the success function so that when the user clicks it checks to see if its been loaded already Something like this I tried but no go if (loadedAlready = false) { $.ajax({ type: POST, url: '/manage/account/edit', cache: true, success: function(data){ loadedAlready = true; $('.loading').fadeOut('normal').remove(); $(#test).slideToggle('slow').toggleClass(hidden); $(#testForm).html(data).slideToggle('slow'); } }); } else { $('.loading').fadeOut('normal').remove(); $(#test).slideToggle('slow').toggleClass(hidden); $(#testForm).slideToggle('slow'); } Dave
[jQuery] Validate remote:
I have a simple test to check if email is registered already using validate remote. But am not getting any error message. I am watching the activity using Firefox and see the script checking the php script and i see the error being reported in my debug() Array ( [agree] = You must verify that you understand and wish to procede. [email] = This email account is already registered. ) My js rule looks like: 'data[Profile][email]':{required: true, email:true, remote: {url: /manage/profile/validate.php,type: post}}, And message: 'data[Profile][email]': { required: * JS required email address., email: * JS email address., remote: * Remote address}, Can someone point out what I am doing wrong? Thnks, Dave
[jQuery] Append Help
I am uploading images and once uploaded they appear in my sortable list. I have success response: $('li/li').appendTo('#sortable').fadeIn('slow').html(response); page code: ul id=sortable class=files liimage1/li - are there when the page loads liimage2/li - are there when the page loads liimage3/li - are there when the page loads liimage4/li - newly added image appears here but I would like it to appear above image1 /ul But I would like to have it appear at the top. What I have adds it to the very bottom of the list. How can I have it appear at the top of the list? Thanks Dave
RE: [jQuery] Append Help
That certainly was fast. Thanks, just what i needed. Dave _ From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-04-09 1:35 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Append Help shot in the dark here... but prependTo()? On Wed, Nov 4, 2009 at 9:01 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am uploading images and once uploaded they appear in my sortable list. I have success response: $('li/li').appendTo('#sortable').fadeIn('slow').html(response); page code: ul id=sortable class=files liimage1/li - are there when the page loads liimage2/li - are there when the page loads liimage3/li - are there when the page loads liimage4/li - newly added image appears here but I would like it to appear above image1 /ul But I would like to have it appear at the top. What I have adds it to the very bottom of the list. How can I have it appear at the top of the list? Thanks Dave -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
RE: [jQuery] Append Help Issue
Ok i changed the code to: $('li/li').prependTo('#sortable').fadeIn('slow').html(response); My response is already in a li which has variables from the php script so I need it returned in the response. So I end up with being added to the sortable list (extra li set i dont need) li li id =my_idcode. /li /li How can I just insert the response to the #sortable at the top? Thanks again, Dave _ From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] Sent: November-04-09 1:40 PM To: jquery-en@googlegroups.com Subject: RE: [jQuery] Append Help That certainly was fast. Thanks, just what i needed. Dave _ From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-04-09 1:35 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Append Help shot in the dark here... but prependTo()? On Wed, Nov 4, 2009 at 9:01 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am uploading images and once uploaded they appear in my sortable list. I have success response: $('li/li').appendTo('#sortable').fadeIn('slow').html(response); page code: ul id=sortable class=files liimage1/li - are there when the page loads liimage2/li - are there when the page loads liimage3/li - are there when the page loads liimage4/li - newly added image appears here but I would like it to appear above image1 /ul But I would like to have it appear at the top. What I have adds it to the very bottom of the list. How can I have it appear at the top of the list? Thanks Dave -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
RE: [jQuery] Append Help Issue
I went with $(response).fadeIn('slow').prependTo('#sortable'); It works as I need it but not sure if that coded right. So the response fades in slow and inserted into the top of the sortable list Dave _ From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-04-09 2:17 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Append Help Issue Try prepend() instead of prependTo()? http://docs.jquery.com/Manipulation/prepend On Wed, Nov 4, 2009 at 9:40 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Ok i changed the code to: $('li/li').prependTo('#sortable').fadeIn('slow').html(response); My response is already in a li which has variables from the php script so I need it returned in the response. So I end up with being added to the sortable list (extra li set i dont need) li li id =my_idcode. /li /li How can I just insert the response to the #sortable at the top? Thanks again, Dave _ From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] Sent: November-04-09 1:40 PM To: jquery-en@googlegroups.com Subject: RE: [jQuery] Append Help That certainly was fast. Thanks, just what i needed. Dave _ From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: November-04-09 1:35 PM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Append Help shot in the dark here... but prependTo()? On Wed, Nov 4, 2009 at 9:01 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am uploading images and once uploaded they appear in my sortable list. I have success response: $('li/li').appendTo('#sortable').fadeIn('slow').html(response); page code: ul id=sortable class=files liimage1/li - are there when the page loads liimage2/li - are there when the page loads liimage3/li - are there when the page loads liimage4/li - newly added image appears here but I would like it to appear above image1 /ul But I would like to have it appear at the top. What I have adds it to the very bottom of the list. How can I have it appear at the top of the list? Thanks Dave -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Sort after insert append?
I have a list of Educations that are ordered by Date Completed. Same page I have an ajax form to add new education. How can I insert the new education where it should go chronologically? Example: 2005 1997 And user add's new Education for 2002 how can I have that be inserted between 2005 and 1997? Thanks, Dave
[jQuery] Re: Sort after insert append?
Sorry, my bad. Each Education is in its own div. They are sorted on initial page load thru php. The id's are generated unique Id's so they look like 125kj6756 and so on. Not sorted by id but by the complated date inside the DIV prior to the page loading. div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2007/dd /dl div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2004/dd /dl div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2001/dd /dl From: Charlie [mailto:charlie...@gmail.com] Sent: October-26-09 5:40 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Sort after insert append? a lot depends on html , are these lists, tables, text etc?? hard to guess what you need Dave Maharaj :: WidePixels.com wrote: I have a list of Educations that are ordered by Date Completed. Same page I have an ajax form to add new education. How can I insert the new education where it should go chronologically? Example: 2005 1997 And user add's new Education for 2002 how can I have that be inserted between 2005 and 1997? Thanks, Dave
[jQuery] Re: Sort after insert append?
Right on. Looks good. thanks Will try to integrate it into my app. Dave _ From: Charlie [mailto:charlie...@gmail.com] Sent: October-26-09 8:06 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Sort after insert append? made an example that will do what you need based on parsing the text in the dd to determine years there are simpler ways with classes that could be added at server but this works with just the html provided. I used a select to show will insert before and after list if applicable http://jsbin.com/inayo Dave Maharaj :: WidePixels.com wrote: Sorry, my bad. Each Education is in its own div. They are sorted on initial page load thru php. The id's are generated unique Id's so they look like 125kj6756 and so on. Not sorted by id but by the complated date inside the DIV prior to the page loading. div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2007/dd /dl div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2004/dd /dl div id=education_{id}' html code dl dteducation title/dt ddSchool/dd ddCompleted 2001/dd /dl From: Charlie [mailto:charlie...@gmail.com] Sent: October-26-09 5:40 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Sort after insert append? a lot depends on html , are these lists, tables, text etc?? hard to guess what you need Dave Maharaj :: WidePixels.com wrote: I have a list of Educations that are ordered by Date Completed. Same page I have an ajax form to add new education. How can I insert the new education where it should go chronologically? Example: 2005 1997 And user add's new Education for 2002 how can I have that be inserted between 2005 and 1997? Thanks, Dave
[jQuery] Toggle Help
I am trying to toggle two different views on the page. I have the users personal info in div id=edit_personalcontent/ So when the user clicks edit the content gets replaced with a form url: /manage/personal/edit, What would be the best way to do this/ So if they click edit the content gets replaced with the form, if they hit cancel the form gets replaces with the original content? script type= text/javascript $(document).ready(function(){ $(#edit_personal).click(function(){ $(#edit_personal).toggle().ajax(function(){ url: /manage/personal/edit, cache: false }); return false; }); }); /script Thanks, Dave
[jQuery] Sortable Help
I am sorting but the data being sent is in wrong format. Response headers: data = entry[]=cf43c5caa5eentry[]=1cb5758d6aaentry[]=ee713a3034aentry[]=d32cea34 83f key = entry_0[] but it should be entry[0]=cf43c5caa5eentry[1]=1cb5758d6aaentry[2]=ee713a3034aentry[3]=d32c ea3483f script looks like $(#sortable).sortable({ update: function() { $.post('/manage/entries/order/', { data: $(#sortable).sortable(serialize), key: 'entry_0[]' }); } }); Can someone point out where I went wrong? Thanks Dave
[jQuery] Prevent Select from opening.
I have a select input that when clicked i want to prevent from dropping down. How can this be done? I only have this so far: script type=text/javascript $(document).ready(function(){ $(#JobStateId).mousedown(function(){ alert('clicked'); return false; }); }); /script Dave
[jQuery] Ideas how to build?
I came across this select / checkbox setup at http://monster.ca/ for job search and was wondering if anyone has seen some thing like this jquery related? Not the drop/slide down. But when you click on the select input it shows a checkbox list instead of normal select options Thanks, Dave
[jQuery] Fade in/ out image
How can i remove the image in an id but keep the div? div id = something image here /div I want to fade the image out then remove it completely from the div keeping the div so the new content can be loading inside it? Dave
[jQuery] Selectors .each
I am trying to add a class to the first dl item each time it appears inside set_list $('.set_list').each(function(){ $('dl.set:first').addClass('first'); }); This appers to only add 'first' to the first dl and not each one in each set_list I have my code like below..i simply want to add 'first' to the first dl in each set_list set_list dl = i want first added here dt dd dl dt dd set_list dl = i want first added here dt dd dl dt dd Know where i went wrong? Dave
[jQuery] Re: Selectors .each
Right on. Thanks for pointing that out and clearing it up for me. I'm assuming that the .set_list element actually is the parent of those DL/DT/DD elements. you are correct. Thanks again Dave -Original Message- From: Michael Geary [mailto:m...@mg.to] Sent: October-01-09 3:03 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Selectors .each When you write $('dl.set:first') you are saying, make a list of all DL elements in the document that have the 'set' class, and give me the first element in that list. Putting this code inside the .each() loop doesn't change that. The $('dl.set:first') selector stands on its own. The code you want is: $('.set_list').each( function() { $(this).find('dl.set:first').addClass('first'); }); By writing $(this).find('dl.set:first') you are saying, Start with 'this', which is the '.set_list' element for this particular iteration of the .each() loop. Now find the DL elements with the 'set' class *inside* this '.set_list'. Give me the first of those elements. I'm assuming that the .set_list element actually is the parent of those DL/DT/DD elements. -Mike On Thu, Oct 1, 2009 at 8:19 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am trying to add a class to the first dl item each time it appears inside set_list $('.set_list').each(function(){ $('dl.set:first').addClass('first'); }); This appers to only add 'first' to the first dl and not each one in each set_list I have my code like below..i simply want to add 'first' to the first dl in each set_list set_list dl = i want first added here dt dd dl dt dd set_list dl = i want first added here dt dd dl dt dd Know where i went wrong? Dave
[jQuery] Ajax / Form Validation
I have a form that gets submitted via AJAX, now i want to add the validation but cant make sense of it. Using malsup form script to submit, Now I would like to incorporate the jQuery Validation Plug-in found on http://jquery.bassistance.de/validate/demo/index.html I currently have this so submit: script type=text/javascript $(document).ready(function() { $('#testForm').live(click, function(){ $('#testForm').bind('submit', function() { var queryString = $('#testForm').formSerialize(); var id = '?php echo $id; ?'; $(this).ajaxSubmit({ type:'post', url: '/manage/experiences/edit/123', data: queryString, target: '#updateMe', success: afterEffects }); return false; }); }); function afterEffects () { $.fn.colorbox.close(); } }) /script But how do I add in the validation script into this? Any help would be greatly appreciated. Thanks Dave
[jQuery] Form validation
I cant get the validation in my form to work. Using malsup to sumbit and trying to add validate.js plugin but it wont work. I can submit the form on its own but adding the validation breaks it. I followed the examples for the validate but what about bind submit? Surely someone has sumbitted a form via ajax and validated it first. Please help me get this started. Dave
[jQuery] Re: Ajax / Form Validation
This is my script now. script type=text/javascript $(document).ready(function() { $('#testForm').bind('submit', function() { $(this).validate(validation_options); var valid = $(this).valid(); if (valid) { var queryString = $('#testForm').formSerialize(); //alert(queryString); $(this).ajaxSubmit({ type: 'post', url: '/manage/experiences/edit/123', data: queryString, target: '#testUpdate', success:afterEffects }); return false; } }); function afterEffects () { $.fn.colorbox.close(); } var validation_options = { // set your options here rules: { field: required } }; }); /script When I hit submit it tries to access the url by the browser. Check the net activity and see _method PUT data[Experience][city] LosAngeles data[Experience][country_id]38 data[Experience][finished] 2007 data[Experience][position] Customer Service Rep data[Experience][respons] sweet sf data[Experience][start] 1975 data[Experience][state_id] 15 field Nothing is working. Ideas? Dave -Original Message- From: James [mailto:james.gp@gmail.com] Sent: October-02-09 12:19 AM To: jQuery (English) Subject: [jQuery] Re: Ajax / Form Validation Here's a simplified version of what you want to do: $('#testForm').bind('submit', function() { $(this).validate(validation_options); var valid = $(this).valid(); if (valid) { // do your ajax } }); var validation_options = { // set your options here }; On Oct 1, 10:52 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have a form that gets submitted via AJAX, now i want to add the validation but cant make sense of it. Using malsup form script to submit, Now I would like to incorporate the jQuery Validation Plug-in found onhttp://jquery.bassistance.de/validate/demo/index.html I currently have this so submit: script type=text/javascript $(document).ready(function() { $('#testForm').live(click, function(){ $('#testForm').bind('submit', function() { var queryString = $('#testForm').formSerialize(); var id = '?php echo $id; ?'; $(this).ajaxSubmit({ type: 'post', url: '/manage/experiences/edit/123', data: queryString, target: '#updateMe', success: afterEffects }); return false; }); }); function afterEffects () { $.fn.colorbox.close(); } }) /script But how do I add in the validation script into this? Any help would be greatly appreciated. Thanks Dave
[jQuery] Re: Prevent jagged text in IE
I tried adding a solid bg color to the css to test quickly but it still rendered jagged. So I figured the easiest way is to scrap the fade all together. LOL Problem solved. Dave -Original Message- From: James [mailto:james.gp@gmail.com] Sent: September-25-09 11:26 PM To: jQuery (English) Subject: [jQuery] Re: Prevent jagged text in IE What happens if you set a solid background-color to the element that holds the text? On Sep 25, 3:08 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Thanks, Will give it a shot. Dave _ From: Rick Faircloth [mailto:r...@whitestonemedia.com] Sent: September-25-09 9:48 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Prevent jagged text in IE I include a reference to a file with this jQuery code in every page to solve that problem, Dave. Best solution I've found so far. I got it from someone, somewhere, but don't remember who. Rick jQuery.fn.fadeIn = function(speed, callback) { return this.animate({opacity: 'show'}, 750, function() { if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; jQuery.fn.fadeOut = function(speed, callback) { return this.animate({opacity: 'hide'}, 750, function() { if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; jQuery.fn.fadeTo = function(speed,to,callback) { return this.animate({opacity: to}, 750, function() { if (to == 1 jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Michael Geary Sent: Friday, September 25, 2009 8:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Prevent jagged text in IE Make sure the text opacity is 100%. Don't fade it in. IE renders non-antialiased text when opacity is less than 100%. If that's not it, post a link to a test page. -Mike On Fri, Sep 25, 2009 at 4:56 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have content that loads into a div and in every browser except IE it renders fine. In the wonderful IE it comes in jagged...sometimes it snaps after and looks normal but for the most part its all jagged. The page is a white bg with text rendering into of it. Howcan I fix this so it looks normal? Not using a crazy font, just font-family:Helvetica, Arial, sans-serif; 1em Ideas? Suggestions? Thanks Dave
[jQuery] Update Text or HTML
I have a div inside a div: div class=heading id=some_idSome Title Text div class=manage_optionsAdd | Edit | Delete/div /div I simply want to change the Some Title Text and leave the Add Edit Delete as is but my script type=text/javascript $(document).ready(function() { $('.heading').html(My New Title); }) /script Strips everything out, how can i select to only change the heading text? Thanks Dave
[jQuery] Prevent jagged text in IE
I have content that loads into a div and in every browser except IE it renders fine. In the wonderful IE it comes in jagged...sometimes it snaps after and looks normal but for the most part its all jagged. The page is a white bg with text rendering into of it. Howcan I fix this so it looks normal? Not using a crazy font, just font-family:Helvetica, Arial, sans-serif; 1em Ideas? Suggestions? Thanks Dave
[jQuery] Re: Prevent jagged text in IE
Thanks, Will give it a shot. Dave _ From: Rick Faircloth [mailto:r...@whitestonemedia.com] Sent: September-25-09 9:48 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Prevent jagged text in IE I include a reference to a file with this jQuery code in every page to solve that problem, Dave. Best solution I've found so far. I got it from someone, somewhere, but don't remember who. Rick jQuery.fn.fadeIn = function(speed, callback) { return this.animate({opacity: 'show'}, 750, function() { if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; jQuery.fn.fadeOut = function(speed, callback) { return this.animate({opacity: 'hide'}, 750, function() { if (jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; jQuery.fn.fadeTo = function(speed,to,callback) { return this.animate({opacity: to}, 750, function() { if (to == 1 jQuery.browser.msie) this.style.removeAttribute('filter'); if (jQuery.isFunction(callback)) callback(); }); }; From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Michael Geary Sent: Friday, September 25, 2009 8:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Prevent jagged text in IE Make sure the text opacity is 100%. Don't fade it in. IE renders non-antialiased text when opacity is less than 100%. If that's not it, post a link to a test page. -Mike On Fri, Sep 25, 2009 at 4:56 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have content that loads into a div and in every browser except IE it renders fine. In the wonderful IE it comes in jagged...sometimes it snaps after and looks normal but for the most part its all jagged. The page is a white bg with text rendering into of it. Howcan I fix this so it looks normal? Not using a crazy font, just font-family:Helvetica, Arial, sans-serif; 1em Ideas? Suggestions? Thanks Dave
[jQuery] Re: jQuery in loaded content doesn't work
I ran into the same thing. I have the apple style slider that is on a page that gets loaded into a div as content. And it no longer works. I would be interested in following this post to see if any headway is made in this particular topic. Dave -Original Message- From: mstone42 [mailto:si...@rocketmail.com] Sent: September-24-09 11:46 AM To: jQuery (English) Subject: [jQuery] Re: jQuery in loaded content doesn't work Thanks, Chris! I'll give livequery a try.
[jQuery] Update Div after ajax submit
I am using the jquery.form.js script and submit a form just fine. My Question is how can update an additional div after the form is sumbitted. Example h1title here /h1 = might say something like Edit you Green Earth Post Page content code. div id='formHere' form. /div So the form loads in div id='formHere', submit and fades out new content is replaced where the form was staright forward stuff. But the form has a title textfield which is where the h1 tag is so when they submit the form if they changed the title i want the new title to be display there. So if they change the title from Green Earth Post to Enviro Plan in the form the h1 tag will now show Enviro Plan. Dave
[jQuery] Toggle Fade
I am trying to build a simple little effect when a user checks / un-checks a checkbox a specific div will fade in or out depending on the check state. I found lots of examples using toggle but I do not want to completely hide the div, only fade it to 50% or back to 100% Ideas anyone? Thanks Dave
[jQuery] Help with error script
I have an ajax function that checks fields to validate and display error messages. There are multiple messages depending on the error per field in some cases, to short, to long, already taken, invalid, cant be empty and so onyou get the idea. My function is like this: function(error) { if(error.length != 0) { if ( $('#' + fieldName + '-exists').length == 0 ) { $('#' + fieldName).after('div class=error-message id='+ fieldName +'-exists' + error + '/div'); } } else { $('#' + fieldName + '-exists').remove(); } }); But the error never changes once 1 is called so if to short it says too shortfix the problem and it only shows too short never any other message. How can i remove the message if its fixed but still return anothererror if it exists? I tried if ( $('#' + fieldName + '-exists').length != error ) so if the error is different display the error but it doesnot remove the original error Ideas? Thanks Dave
[jQuery] Help with getting variable
Hoping for some simple help here. I have this structure in my forms name=data[User][username] But depending on the form it the ['User'] section will change throught the site. How can I pull the User as a variable? The script has something like this: $.post('/ajax_validate/users/', { field: fieldName, value: fieldValue }, Where I want to add the variable like $.post('/ajax_validate/'+myVarHere, { field: fieldName, value: fieldValue }, Thanks, Dave
[jQuery] Selector bind help
I have a simple form field that runs a query. I have $('#Query').bind('keyup', function() { ...delay then search so after key up and delay it runs the search. Now when I click on the #query field the dropdown appears with my previous search text...if i select one it goes into the #query field but nothing happens becasue the script is waiting for keyup action. Can I add multiple events to trigger the query? If so how or what would be the best idea? Thanks, Dave
[jQuery] live() help
I have this on a page that gets loaded into a div but its not working when loaded. I originally had the page load normally in the browser and it worked, only since loading it into the div has it stopped. Not sure if it has anything to do with it but i want to add .live() to the function and give it a try but no idea where to add it just to see if that does anything. Or does anyone have any ideas that might help me to get this working again. $(window).ready(function() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); }); Thanks, Dave
[jQuery] Re: live() help
Correctpage initially loads with 3 tabs. Clicking on 1 tab loads the gallery into the current page. div id=ajax_contentall content loads here/div Will try you suggestion about removing $(window).ready and see what happens. Dave From: Cam Spiers [mailto:camspi...@gmail.com] Sent: September-07-09 8:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: live() help Hi I'm not exactly sure what you mean by loaded into a div but I assume that this script is being loaded into the document after the document/window is already ready. It is possible you need to remove the $(window).ready event. Maybe the bound ready functions have been triggered already and are not being triggered again. Regards, Cam On Tue, Sep 8, 2009 at 10:29 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have this on a page that gets loaded into a div but its not working when loaded. I originally had the page load normally in the browser and it worked, only since loading it into the div has it stopped. Not sure if it has anything to do with it but i want to add .live() to the function and give it a try but no idea where to add it just to see if that does anything. Or does anyone have any ideas that might help me to get this working again. $(window).ready(function() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); }); Thanks, Dave
[jQuery] Re: live() help
Still no go. I now have this: script type=text/javascript charset=utf-8 $(document).ready(function() { init_gallery(); function init_gallery() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); alert(id); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } }); /script Works if not loaded into a div, will not work if loaded into div, yet the alert(id); still shows in both cases. Ideas? Dave From: Cam Spiers [mailto:camspi...@gmail.com] Sent: September-07-09 8:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: live() help Hi I'm not exactly sure what you mean by loaded into a div but I assume that this script is being loaded into the document after the document/window is already ready. It is possible you need to remove the $(window).ready event. Maybe the bound ready functions have been triggered already and are not being triggered again. Regards, Cam On Tue, Sep 8, 2009 at 10:29 AM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have this on a page that gets loaded into a div but its not working when loaded. I originally had the page load normally in the browser and it worked, only since loading it into the div has it stopped. Not sure if it has anything to do with it but i want to add .live() to the function and give it a try but no idea where to add it just to see if that does anything. Or does anyone have any ideas that might help me to get this working again. $(window).ready(function() { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); }); Thanks, Dave
[jQuery] Validation question
I have this script $(document).ready( function() { $('#username').blur( function () { fieldName = $(this).attr('id'); fieldValue = $(this).val(); $.post('/users/ajax_validate', { field: fieldName, value: fieldValue }, function(error) { if(error.length != 0) { $('#username').after('div class=error-message id='+ fieldName +'-exists' + error + '/div'); } else { $('#' + fieldName + '-exists').remove(); } }); }); }); Which sends a requet to determine if the username is taken...pretty simple if so it displays Please choose another message. My problem is if the user goes back to the field and then leaves without changing it it sends the request again and then shows Please choose another name Please choose another name How can I modify the script so if there is an error and not fixed to leave the message and not repeat it? Dave
[jQuery] Load Ajax content from flash XML
I have a flash navigation which gets the URL's from an XML file like: item pathcontent/images/4.jpg/path urlhttp://www.mysite.com/url target_blank/target bar_color0x66/bar_color bar_transparency70/bar_transparency slideShowTime5/slideShowTime /item Does anyone know how to load the URL into a div on that page? Thanks, Dave
[jQuery] SlideTo Help
I have a standard li id=a_?php echo $id; ? code link /li x 10 list. What I would like to do is when the link is clicked inside any of the li's scroll the page to the top of the browser to the top of that li? How would I set something like that up? Dave
[jQuery] POST GET help
I have $('#JobQuery').keyup(function(){ $.post(/jobs/search/, $(#JobSearchForm).serialize()); }); So it acts as a live search function. Inspect the browser activity and I can see the searches being performed. How can I get the data in the response to load into a div? Dave
[jQuery] Toggle Help
I want to build add a favourites type widget into my site. Just so a user can bookmark a post they like. So I have my standard paginated view with various posts and a star beside each post. Solid star = bookmarked, empty star = not bookmarked I have the save/delete bookmark working the star only changes on a page refresh. How would I use toggle for something like this? So when the user clicks on the star it changes to the opposite of what it is? And how do I then use the toggle to determine what star to display on page load? Ideas? Dave
[jQuery] Add / Remove Class help
I have 2 class options .bookmarked and .not div id=b_97fd0f class=bookmarked not /div Or div id=b_97fd0f class=bookmarked /div My js looks like $(.bookmarked,.bookmarked not).click(function() { var url_id = $(this).attr('id').split('_'); var status = $(this).attr('class'); //alert(status); $.ajax({ type: POST, url: '/bookmarks/bookmark/'+url_id[1], success: function(){ if (status = bookmarked not) { //creating a bookmark $('#b_'+url_id[1]).removeClass('not'); } else if (status = bookmarked){ //deleting the bookmark $('#b_'+url_id[1]).addClass('not'); } } }); return false; }); If I click on a .bookmarked not link it removes the not class, but if I click on a bookmarked link it does not add the not class. Now the bookmarks are being created and deleted in the database...just not changingthe div class. Ideas where I went wrong? Dave
[jQuery] Validation Error message help
I have this script: $(document).ready( function() { $('#username').blur( function () { fieldName = $(this).attr('id'); fieldValue = $(this).val(); $.post('/users/ajax_validate', { field: fieldName, value: fieldValue }, function(error) { if(error.length != 0) { $('#username').after('div class=error-message id='+ fieldName +'-exists' + error + '/div'); } else { $('#' + fieldName + '-exists').remove(); } }); }); }); So when the user leaves the field it checks validation. If error it shows an error message. Everything is working fine except if the user goes back to the field where there was an error and does not chnge anything and leaves the field again the error message is duplicated. So they enter a username peter it says Please choose a different name if they go back to the username and thenleavewith out changing peter i now have: Please choose a different name Please choose a different name What do I have to change / add so that only 1 message will appear? Thanks Dave
[jQuery] Pagination
Does anyone know how or if possible to remember where you were at in pagination? Example a user clicks 1, 2, 3, finds what they want on the third page and clicks a link...nope not what they were looking for they click back which now brings them back to pagination page 1 when it would be nice to remember that they were on the 3rd page and automatically return them there. Dave
[jQuery] Remove help
I have append to add a loading div. But once loaded i want to fade it out and remove it. I have: script type= text/javascript/*![CDATA[*/ $(document).ready(function(){ $('#content').append('div id=load/div'); $('#load').fadeIn('normal'); $('#content').load('/?php echo $url ; ?/profile/'); $('#load').fadeOut('normal' , function() { $('#load').remove(); }); }); /script But it does not remove the #load div...so looking at firebug the load div gets added everytime a user clicks a link div id=load style=display: none;/ div id=load/ div id=load/ div id=load/ div id=load/ How can I remove the div once it done loading? Dave
[jQuery] Re: Remove help
Sorry...missed my morning coffee :( Posted the wrong code But I got it with this: $('a.profile_data').click(function(){ var x_url = $(this).attr('href'); $('#content').append('div id=load/div'); $('#loadHere').fadeOut('fast', function(){ $('#load').fadeIn('normal'); $('#loadHere').load(x_url, function(){ $('#load').fadeOut('normal' , function() { $('#load').remove(); }); $('#loadHere').fadeIn('fast'); _ajaxInit(); }); }); return false; }); Dave -Original Message- From: amuhlou [mailto:amysch...@gmail.com] Sent: August-06-09 10:56 AM To: jQuery (English) Subject: [jQuery] Re: Remove help where is the click function in your javascript? I don't see it in the snippet you posted. it may work better to fade out the loading div as a callback to your load method: $('#content').load('/?php echo $url ; ?/profile/', function(){ $('#load').fadeOut().remove(); }); On Aug 6, 9:17 am, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I have append to add a loading div. But once loaded i want to fade it out and remove it. I have: script type= text/javascript/*![CDATA[*/ $(document).ready(function(){ $('#content').append('div id=load/div'); $('#load').fadeIn('normal'); $('#content').load('/?php echo $url ; ?/profile/'); $('#load').fadeOut('normal' , function() { $('#load').remove(); }); }); /script But it does not remove the #load div...so looking at firebug the load div gets added everytime a user clicks a link div id=load style=display: none;/ div id=load/ div id=load/ div id=load/ div id=load/ How can I remove the div once it done loading? Dave
[jQuery] Fade in / Out
I was wondering how do you make text fade in for a specific amount of time then fade out. I have the fade in / out part..i just cant figure out the duration so it stays there after fading in for 5 seconds then fades out. Dave
[jQuery] append help
I want to add .loading class before an element (#admin_content) so when a user clicks on a link it add the loading class before the #admin_content DIV but just can figure out to add the div class=loading/div I do not want to load the pages up with loading div tags all over the site. $('a.admin_nav').click(function(){ var url = $(this).attr('href'); $('#admin_content').fadeOut('fast', function(){ // want to add the loading step here $('#admin_content').load(url, function(){ //want to remove the loading class $('#admin_content').fadeIn('fast'); }); }); return false; }); Can someone point me in the right direction? Dave
[jQuery] Newbie Question
I have a standard php page with some jquery going on its working fine. Now I want to take that page and load it into a div on a different page (tabbed layout pretty much) but when I do the script no longer works when the page loads into the div. SCRIPT CURRENTLY ON THE PHP PAGE THAT WORKS WHEN VIEWED DIRECTLY IN BROWSER script type=text/javascript $(document).ready(function() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); }; /script How can I get it to still work when loaded into the DIV? Thanks Dave
[jQuery] Re: Newbie Question
Nope...no go. All I have for the tabs are just straight links calling the script to load the page. $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); }); }); return false; }); Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 12:50 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } _ajaxInit(); /script if that doesn't work, call _ajaxInit() on the tabs callback function Dave Maharaj :: WidePixels.com wrote: I have a standard php page with some jquery going on its working fine. Now I want to take that page and load it into a div on a different page (tabbed layout pretty much) but when I do the script no longer works when the page loads into the div. SCRIPT CURRENTLY ON THE PHP PAGE THAT WORKS WHEN VIEWED DIRECTLY IN BROWSER script type=text/javascript $(document).ready(function() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } /script How can I get it to still work when loaded into the DIV? Thanks Dave
[jQuery] Re: Newbie Question
3 Errors syntax error [Break on this error] });\n (line 167) syntax error [Break on this error] });\n (line 6) _ajaxInit is not defined [Break on this error] _ajaxInit();\n That's what I see now but still nothing good happening. dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 1:19 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question yeah, use the modified script and add _ajaxInit(); to the callback; $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); _ajaxInit(); }); }); return false; }); Dave Maharaj :: WidePixels.com wrote: Nope...no go. All I have for the tabs are just straight links calling the script to load the page. $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); }); }); return false; }); Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 12:50 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } _ajaxInit(); /script if that doesn't work, call _ajaxInit() on the tabs callback function Dave Maharaj :: WidePixels.com wrote: I have a standard php page with some jquery going on its working fine. Now I want to take that page and load it into a div on a different page (tabbed layout pretty much) but when I do the script no longer works when the page loads into the div. SCRIPT CURRENTLY ON THE PHP PAGE THAT WORKS WHEN VIEWED DIRECTLY IN BROWSER script type=text/javascript $(document).ready(function() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } /script How can I get it to still work when loaded into the DIV? Thanks Dave
[jQuery] Re: Newbie Question
Yes I have. Might be dumb of me but I will ask. Originally the script type=text/javascript /script and the needed js files were on the page specifically needing it. But now that I am loading that page into one... Where do the scripts and files go? Do they now go to the page that they will be loaded into or do they stay on their own original page? Page 1 page1.js script type=text/javascript /script Page 2 page2.js script type=text/javascript /script Since Page 2 is going to be loaded into page 1 DIV do I move the page2 scripts to page 1? Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 1:34 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question Have you updated the original script to my one? script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } /script Dave Maharaj :: WidePixels.com wrote: 3 Errors syntax error [Break on this error] });\n (line 167) syntax error [Break on this error] });\n (line 6) _ajaxInit is not defined [Break on this error] _ajaxInit();\n That's what I see now but still nothing good happening. dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 1:19 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question yeah, use the modified script and add _ajaxInit(); to the callback; $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); _ajaxInit(); }); }); return false; }); Dave Maharaj :: WidePixels.com wrote: Nope...no go. All I have for the tabs are just straight links calling the script to load the page. $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); }); }); return false; }); Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 12:50 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } _ajaxInit(); /script if that doesn't work, call _ajaxInit() on the tabs callback function Dave Maharaj :: WidePixels.com wrote: I have a standard php page with some jquery going on its working fine. Now I want to take that page and load it into a div on a different page (tabbed layout pretty much) but when I do the script no longer works when the page loads into the div. SCRIPT CURRENTLY ON THE PHP PAGE THAT WORKS WHEN VIEWED DIRECTLY IN BROWSER script type=text/javascript $(document).ready(function() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id
[jQuery] Re: Newbie Question
Just local machine right now...nothing online unfortunately. I am using CakePHP which allows me to add the js files I need for each page individually. So I have 1 page that has a horizontal slider like the one on the Apple MAC site..which works if I access the page directly. But when I load that into a div on another page it stops working. That's where I am stuck -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 2:01 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question Do you have an online example so I can get a better picture of just what you are trying to do? Dave Maharaj :: WidePixels.com wrote: Yes I have. Might be dumb of me but I will ask. Originally the script type=text/javascript /script and the needed js files were on the page specifically needing it. But now that I am loading that page into one... Where do the scripts and files go? Do they now go to the page that they will be loaded into or do they stay on their own original page? Page 1 page1.js script type=text/javascript /script Page 2 page2.js script type=text/javascript /script Since Page 2 is going to be loaded into page 1 DIV do I move the page2 scripts to page 1? Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 1:34 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question Have you updated the original script to my one? script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } /script Dave Maharaj :: WidePixels.com wrote: 3 Errors syntax error [Break on this error] });\n (line 167) syntax error [Break on this error] });\n (line 6) _ajaxInit is not defined [Break on this error] _ajaxInit();\n That's what I see now but still nothing good happening. dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 1:19 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question yeah, use the modified script and add _ajaxInit(); to the callback; $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); _ajaxInit(); }); }); return false; }); Dave Maharaj :: WidePixels.com wrote: Nope...no go. All I have for the tabs are just straight links calling the script to load the page. $('a.profile_data').click(function(){ var url = $(this).attr('href'); //alert(url); $('#loadHere').fadeOut('fast', function(){ $('#loadHere').load(url, function(){ $('#loadHere').fadeIn('fast'); }); }); return false; }); Dave -Original Message- From: Liam Potter [mailto:radioactiv...@gmail.com] Sent: August-04-09 12:50 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Newbie Question script type=text/javascript function _ajaxInit() { $(a.group).fancybox( { 'overlayShow': true }); }); window.onload = function () { $('.sliderGallery').each(function(){ var id_parts = $(this).attr('id').split('_'); var id = id_parts[id_parts.length - 1]; var container = $('#sliderGallery_' + id) ; var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); } }); }); } _ajaxInit(); /script if that doesn't