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
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] 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] 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: $("form").bind("submit", function() { var $this = $(this); var form_id = $this.closest('form').attr("id"); uRec('#' + form_id); return false; }); 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. > > > > > > > > $("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 > }) > > > > > 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
Ok so this is where I stand now: Page js: //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); }); 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. > > > > > > > > $("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 > }) > > > > > 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
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: //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; }); 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
I have completely removed the uRec function for now and changed to a regular button, no submit. $("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 }) But not even an alert now. Man ohh man Thanks again for your ideas. Dave
RE: [jQuery] Complicated Question
I have changed my page js to: $("form").bind("submit", function() { var form_id = $(this).attr('id'); alert(form_id); uRec(form_id); return false; }) 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
[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. user records "edit" user records "edit" user records "edit" 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 = '#'; $(form_id).bind("submit", uRec(form_id) { return false; } My script onthe page with all the records is : var form_id = '#<?php echo $form_id ?>'; uRec(form_id); 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
[jQuery] Re: Having hard time with customizing scroll bars
> Where can I find more about those plugins? This search turned up jScrollPane, looks like that is what you want. http://lmgtfy.com/?q=jquery+scroll+plugin
[jQuery] Re: Plugin design pattern (common practice?) for dealing with private functions
> One issue keeps nagging me > though, and that is how to deal with private functions in a > powerful yet elegant manner. I'd recommend taking a look at the way the jQuery UI folks did it. You can get the gist of it from ui.core.js. I didn't really appreciate their design choices until I started trying to solve some of the same problems in my own plugins.
[jQuery] Re: Should I use code.jquery.com?
Google is hosting the file now, you could get it from there: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js
[jQuery] Re: JSON.parse method of JQuery 1.4 will take a mistake in AIR 1.5.X
Ticket created: http://dev.jquery.com/ticket/5822
[jQuery] Re: jQuery 1.4 & LiveQuery
> In 1.4 the built in live() function has been heavily extended, so > perhaps you can switch to using that instead? Agreed, but I think livequery should still work. The error posted there is in blockUI and not livequery anyway. Jon Bennett, can you put up a simple page that is a complete test case? It will probably be simple to diagnose using Firebug.
[jQuery] Re: jQuery 1.4 & LiveQuery
> I've been using LiveQuery a fair bit in my projects, I've just tried > updating to 1.4, and it appears to have broken it. Can you post a link to the simplest test case that shows the problem? It is probably a simple fix.
[jQuery] Re: what's up with zoho jquery forum???
The official forum will at http://forum.jquery.com/ so you might want to head over there and look around. This Google group will be around for a long time and you're free to post here, but at some point we'll turn moderation off and within a few weeks it will most likely be overrun by spammers. http://ejohn.org/blog/google-groups-is-dead/ On Jan 14, 1:22 pm, Patrick wrote: > I tried to get to this forum and ended up at some zoho forum for > jquery. Is this the official forum for jquery?
jquery-en@googlegroups.com
> It works. Is there any documentation on this protocol? Hey, Google always has something. :) http://en.wikipedia.org/wiki/JSON#JSONP The reason jQuery uses a random number there is so that multiple requests can be in progress at once and will get separate functions to run on completion.
[jQuery] Re: So sad, jquery 1.4rc1 continue to leak in ie7
Do you have a link to your leaking test case?
[jQuery] Re: jQuery 1.2.6 clone problem with internet explorer.
If you're really stuck, you could try copying the clone function from 1.3 into 1.2.6.
[jQuery] Re: jQuery stripping HTML tags from Ajax response
Is #thing a THEAD or TBODY tag? That would be the only valid place to append a TR.
[jQuery] Re: Make BlockUI synchronous
When the button is clicked, set a variable to the current time and return false from the handler to cancel the submit. When your ajax completes, do a settimeout for the difference between the variable you set and the min length of time you want to show the blockui. When the settimeout fires it can do the $("#myform").submit() to submit the form. On Jan 12, 11:48 am, Vince wrote: > Hello all, > > I have this and a submit button. > > I then try the following inside my document ready: > > $("#btnSubmit").click(function() { > > $.blockUI({ > theme: true, > title: 'My title', > message: 'My message...', > timeout: 8000 > }); > > return true; > > }); > > Unfortunately the form is being submitted and completely disregards > the timout attribut I've set. > So I'm assuming there isn't a way to make blockUI synchronous and > really wait the timeout time and then, submit the form. > > The reason I'm asking is because I'm having the exact same scenario as > this post:http://osdir.com/ml/jQuery/2009-02/msg02094.html > > I'm using both IE and FF > > In a nutshell, between the blockUI and the return true I make an ajax > call. The time it takes varies a lot...it can be really quick like it > can take 15 seconds... > > When the call is quick, the users barely has the time to view the > blockUI and read what's inside...the form gets submitted but they are > like..."What happened? What was written there? I didn't have enough > time to read"... > > So to avoid, this, I always want a minimum of time for the blockUI to > appear even if the ajax call is quick. > > As for what happens if the ajax call is lets say...15 seconds...well > that's another story! > I'd first like to know if this is even possible...to NOT make my form > submit until it has reached the timeout attribute I've set inside the > blockUI parameters. > > Thanks in advance > Sincerely > > Vince
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
[jQuery] Append prepend?
I cant seem to understand the logic behind these functions. append prepend appendTo, prependTo I have: *** add new li from response here *** content content content 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 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: 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" 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
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" 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(''); > //$('#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
[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(''); //$('#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
[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
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" 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] 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: 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":"this 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 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":"this is a good test<\/p>\r\n"}this is a good test 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: , Message: . Data: , Count: } 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" 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" > 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 > > > saved data will appear here > > > 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 > >
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 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":"this is a good test<\/p>\r\n"}this is a good test 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: , Message: . Data: , Count: } 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" 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" > 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 > > > saved data will appear here > > > So what I need is i guess json success true or false response from > > the form being saved or not then in my success > > >
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":"this is a good test<\/p>\r\n"}this is a good test 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": "this 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 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":"this is a good test<\/p>\r\n"}this is a good test 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: , Message: .
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": "this 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 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":"this is a good test<\/p>\r\n"}this is a good test 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: , Message: . Data: , Count: } 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" 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
[jQuery] Re: Ajax forms help
My response comes back from the server looking like this: (dont 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":"this is a good test<\/p>\r\n"}this is a good test 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: , Message: . Data: , Count: } 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" 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" > 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 > > > saved data will appear here > > > 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 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 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 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" 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 > > saved data will appear here > > 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
[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 saved data will appear here 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
[jQuery] Re: My table tags are getting stripped out.
> Am I missing something? Well, *we're* missing something, like the markup that goes with the code. Can you point to a sample page maybe? Is #CalendarBody the TABLE tag? If so, you should be appending a THEAD or TBODY tag to it. Instead of returning HTML fragments, you might want to return JSON with just the data and then have the client do the formatting. I'm not familiar with the asp.net MVC ContentResult so I don't know if that's possible or not.
[jQuery] Re: jquery 1.2.1 script not working with 1.3.2
> $('t...@class^=child-]').hide().children('td'); Get rid of any @ for attribute selectors. In jQuery 1.3 we went to css standard syntax, which does not use the @.
[jQuery] Re: ie8 and title text value
I think document.title works on all browsers.
[jQuery] Re: PROBLEM WITH ENCODING (HEBREW - WINDOWS-1255) USING REMOTE
Ajax nearly always uses UTF-8 encoding. Can you switch to UTF-8 for the page and server?
[jQuery] Re: Convert a string version of a json array to an actual json array
It worked perfectly! Thanks a lot. Cheers / Dave On Jan 5, 11:53 am, "Md. Ali Ahsan Rana" wrote: > for(var i = 0; i < arrCss.length; i++){ > var snip = arrCss[i].split("___"); > eval("var temp="+snip[1]); > $(snip[0]).css(temp); > > } > > this may work, try it(although i didnt't try yet) > > --http://ranacseruet.blogspot.com
[jQuery] Convert a string version of a json array to an actual json array
Hi Wonder how I can convert a string to a json array. //start code var arrCss = ["a___{'color':'red','font-weight':'bold'}", "h1,h2___ {'color':'blue'}"]; for(var i = 0; i < arrCss.length; i++){ var snip = arrCss[i].split("___"); $(snip[0]).css(snip[1]); } //end code The problem is that .css() treats snip[1] as a string but I need it to handle it as a json array. Bad: .css("{'color':'red','font-weight':'bold'}"); Good: .css({'color':'red','font-weight':'bold'}); Any solution out there? Thanks
[jQuery] Re: $(form).serialize() does not include submit button data
> I would think the submit button data would also be included when doing > $(form_obj).serialize()? When you submit a form manually, the value of the submit button clicked is sent as part of the form. If you serialize the form using Javascript, no button was clicked so none of them are serialized.
[jQuery] Re: Does anybody know when jquery 1.3.3 or 1.4 will be released?
There should be an announcement of another beta within a few days. The stack overflow has been reported/fixed.
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 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" wrote: > > > Works for me: > > >http://jsbin.com/egoto/ > > > - Richard > > > On Wed, Dec 16, 2009 at 8:44 PM, Jason Kaczmarsky wrote: > > > > Yes, I am sure they are the correct class and are showing up properly. > > > > Button press: > > > //loop > > > $("#files").append(''+Files[i]+''); > > > //end loop > > > > Firebug: > > > > > class="file">work.txt SAS Guide.txt > > > > > > > On Dec 16, 7:43 pm, "Smith, Allex" 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] Re: jquery.color.js no longer maintained?
To be sure, you're talking about this plugin? http://plugins.jquery.com/project/color The plugins site is due to get a redesign for the jQuery 1.4 in January and I think that will help some of the plugins that have been neglected. Maybe we can get some people to adopt the plugins that seem to be popular but orphaned.
[jQuery] Re: How to compare data in 2 jQuery data() elements
> var o = $("#original-fields"), n = $("#new-fields"); > if (o != n) { // <-- BRICK WALL > someAJAXFunctionThatSavesTheFieldsThatChanged(); > } > How can I compare the #original-fields data with the #new-fields > data? As it is, the two always differ; I assume this is because they > are different objects. You could JSON.stringify() the two and see if they are the same string. Otherwise it might be more efficient to set a "dirty" flag when any of the fields are changed.
[jQuery] Re: .focus() and non-IE browsers.
> For some reason, it seems that the .focus() method (at least how I'm > using it) isn't properly setting the focus to what I'm specifying. Yeah, I think that may be broken, it's already been reported. http://dev.jquery.com/ticket/5652
[jQuery] Doing something wrong
I have this function for an ajax edit form. $(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; }); }); 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
[jQuery] Re: Why mootools animations is more smooth than jquery?
> ok, I've used some code I had lying around and put dummy content in > there:http://www.tnt.be/bugs/jquery/moovsjquery/ > > I actually don't really see a difference on my Ubuntu box (using FF > 3.6b4), but there's a huge difference on a colleague's G4 (OS X 10.4, > Firefox 3.5.5), so try to find a slow computer to test this on. Jonathan, thanks for doing the demo. Pretty nice demo, by the way! I tried it on my system, but it's a fast Dell notebook running Windows 7. The demo ran smoothly on Firefox 3.5, IE8, Opera 10, and Chrome 3.
[jQuery] Re: Why mootools animations is more smooth than jquery?
> I refrained from replying because the OP seemed trollish, but he has a > point, IMHO. It would be great if someone who knew both frameworks could set up a page that demonstrated a side-by-side case where Mootools has smoother animations than jQuery. Otherwise it's hard do know what might be causing the problem, or even whether there's a problem at all.
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 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? all some none $('a.filter').click(function(){ $(???).addClass('active'); }); Thanks Dave
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: Normal html code with my #newAward form, then at the bottom of the page $(document).ready( function() { setValidation('#newAward', validate_awards); }); 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 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 ); }); 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 a
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 $(document).ready( function() { setValidation( '#newAward', validate_awards ); }); 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 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?
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 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
[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
[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] Dynamically Changing the Stored Height of a Parent Div Based on a Child's Content
I have a comment form that is fed by Disqus. It is in a div that is scrolled with ui.slider. The problem is, I determine the maxScroll by calculating teh difference between the scrolling content and the viewport. Work great all across the site except here. Reason is, the var fot the div's heigh is set when the page loads. Then the Disqus content loads, and the height var doesn't know that the dom is not full of content. SO how can I update the height of a parent div when ever a child's height changes. Any ideas?
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] Re: Need to hide a href title content, but still need it available in the DOM
That worked beautifully!!! Thanks so much for teh help. Dave BTW... They call me CAPTAIN OBVIOUS!!!
Re: [jQuery] JQuery and ColdFusion
I use ColdFusion and jQuery all the time with no problems. In fact, I use it with mach-ii. Looks like you're using fusebox? Just a guess. Calling the CFC directly is your problem. When you do that, it bypasses the application.cfm/cfc, which is normally where your session scope is defined. Because you are not going through the same application scope, your session variables won't be there. Better to create an event (in mach-ii terms) that your application engine can understand and just pass it through that way, just like a normal browser call. instead of: /myapp/model/System.cfc?method=authenticate&returnFormat=json Something like index.cfm?fuseaction=authenticate Then let your framework do the rest. -dave evartt Westside wrote: Hi, I'm trying to use ColdFusion and JQuery but I'm having some problems setting/reading session variables. I have a login box that I use jquery to do the ajax work. In my ajax call I have this snippet $(form).ajaxSubmit({ type: 'POST', dataType: 'json', url: '/myapp/model/System.cfc?method=authenticate&returnFormat=json' success: function(resp, textStatus){ if(resp[0]==true){ window.location.href = 'index.cfm?fuseaction=myapp.home'; } }); So within System.cfc there is a method called "authenticate", in this method I'm trying to set some session variables (e.g, session.email, session.title) that I can reference once the user is logged in. So if the response from the ajax call returns true, the user gets redirected to this other page using window.location.href shown above. For some reason though, these session variables don't exist (session.email, session.title) when I try to cfdump them out on the 'index.cfm?fuseaction=myapp.home' page. I can dump them in the CFC and see that they are getting set correctly, but outside the CFC, they dont show up. Can anyone please shed some light on why I can't see my session variables? It mus thave something to do with calling the CFC directly or something Thanks
[jQuery] Need to hide a href title content, but still need it available in the DOM
I want to disable the behavior of rolling over a link and having the title content display. I realize that removeAttr will do it. But that removes it form the DOM completely. And I will need it later. Is there a way to use disableDefault to just not display the tool tip on roll over? I don't seem to be able to do it. Lemme know. Dave
[jQuery] Re: change the height of a div that is loaded after the jQuery is
It seems like the plugin Live jQuery might be a good answer. Any thoughts? Lemme know
[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 Title Something here Edit $("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(''); $('.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] change the height of a div that is loaded after the jQuery is
I'm developing a comment panel for a blog that uses Disqus. The design is really tight, and the client is insistent that THIS is the layout. You can see it here: http://agave.purebluebeta.com/blog/2009/nov/20/test-entry/ Problem is, the height is changed AFTER my jQuery is loaded. IE, Disqus comes in after the variables are all set. And I need to know the maximum height for the comments panel when ever it is changed because it will grow over time as more comments are added. But that is done with the Disqus code. Something like $(this).live().height(); But live is only tied to events... right? Any tips are welcome. Thanks.
[jQuery] Re: non well-formed
> My Servlet return json string generated with json-lib... for example: > {"descrizione":"Questa è la descrizione del > computer","disponibile":false,"id":1,"nome":"Computer","prezzo": > 123.456} Is this just a formatting issue, or is there really a newline in the string "Questa è la descrizione del computer" ?
[jQuery] Re: Get the below and above
If the table is really big it might be better to use event delegation: $('table').click(function(e){ var $td = $(e.target).closest('td'), $tr = $td.parent(), pos = $tr.children().index($td), $up = $tr.prev().children().eq(pos), $dn = $tr.next().children().eq(pos); $up.css("background-color", "red"); $dn.css("background-color", "blue"); });
[jQuery] Re: imitate link
> > Can make behave as ? > Why would you not just use CSS to style an element > to be bold and not underlined? Definitely the way to go. That way the link works with the keyboard and screen readers as well. Apps that require the mouse drive me crazy.
[jQuery] Re: Problem adding values in select box ()
> but this line $('#state').add(option); is not adding value to the > select box "state" The .add() method only adds the option element to the jQuery object, it doesn't modify the document. You probably wanted this: $('#state').append(option);
[jQuery] Re: Document Click triggered onSubmit
> I'm having a bit of trouble understanding why a click event attached > to the document is being triggered when submitting a form through the > enter key. When you press Enter, Firefox (looks like this wasn't tested in IE) triggers the click event on the default submit button. That bubbles up to the document. Put an event handler on the submit button's click and you'll see what I mean.
[jQuery] Re: Rounding numbers
Try this var test = 3.141592; alert(test.toFixed(2));
[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. $(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; }); }); Dave
[jQuery] Re: Curious as to why a fadeOut() won't work but a hide() does??
> Any other ideas? :) Well, from the code that you originally showed the possible causes were pretty limited. If there is arbitrary code both before and after that line you showed, it could be almost anything! Can you create a simple test case?
[jQuery] Re: Description of filter()
> Yes, I can't say that I don't agree with you. :-) Ha, brilliant > I updated the docs to use fewer negatives. Because the function only > removes an element when it returns an actual Boolean false value, the > wording there ended up a little strange. Still, I think it's probably > an improvement. Thank you and also for being so speedy all the best Dave
[jQuery] Re: find( ':contains( "something with bracket )" ' ) - crashes in firefox 3.5.3
> I already posted this on the jQuery BugTracker, but nobody seems to > notice. Maybe I can get some help here and I hope you don't regard > this a double post. (the link to the bug report > ishttp://dev.jquery.com/ticket/5482) I noticed the bug, thanks for reporting it. Bugs are usually fixed in batches, so most tickets take a while before someone looks into them. It always helps to have a complete test case attached (both html and script) so it's possible to run the test and see the problem immediately. Otherwise someone has to take a few minutes to build one, and you'd be surprised how many times we can't reproduce the problem given the description in the ticket. So finding a workaround in the meantime is usually the best course of action. You could add a patch to your ticket as well, if you (or someone on this thread) looked at the code and can come up with a solution.
[jQuery] Re: Curious as to why a fadeOut() won't work but a hide() does??
My guess: If your function doesn't return false to stop the submit, the browser will start navigating to the submit action page immediately. It's probably starting to fade but the page changes before it's anywhere close to done.
[jQuery] Re: Description of filter()
> Just wondered if the Filter description could be made a little clearer > on:http://docs.jquery.com/API/1.3/Traversing Yes, I can't say that I don't agree with you. :-) I updated the docs to use fewer negatives. Because the function only removes an element when it returns an actual Boolean false value, the wording there ended up a little strange. Still, I think it's probably an improvement.
[jQuery] Description of filter()
Hi jQuery Just wondered if the Filter description could be made a little clearer on: http://docs.jquery.com/API/1.3/Traversing Instead of: "filter(expr) Removes all elements from the set of matched elements that do not match the specified expression(s)." and "filter(fn) Removes all elements from the set of matched elements that do not match the specified function." perhaps have: "filter(expr) Keeps only elements from the set of matched elements that match the specified expression(s)." and "filter(fn) Keeps only elements from the set of matched elements that match the specified function." Reason being that I did have to read the current description a few times before I understood what I was keeping and removing. Then again I often have trouble understanding my girlfriend because she loves using two negatives per sentence: "Do you not want to take time to not use the computer" (the hamsters go on strike...) all the best 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] Re: jQuery form plugin and document.domain failure
.ajaxForm uses $.ajax, which uses XMLHttpRequest. There are some issues with the way xhr interacts with document.domain, independent of jQuery. http://fettig.net/weblog/2005/11/28/how-to-make-xmlhttprequest-connections-to-another-server-in-your-domain/
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 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] 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
[jQuery] Sortable Help
I am trying to send the data in a numbered array but i end up with set[]=56454&set[]=54546522 when i need set[0]=56454&set[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] 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(''); $('.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] 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] Re: Benefit of extending jQuery with a function vs. a JavaScript function?
> Hello, Marty McGee here. I was hoping to open a discussion about the > benefits of extending jQuery with your own custom functions versus > simply writing your functions in JavaScript and calling them without > extending jQuery first. I am not a fan of extending the jQuery object with unrelated application-specific functionality. It avoids polluting the global namespace, but then again it pollutes the jQuery namespace. If jQuery later tries to claim that name for its own uses, you'll have a conflict.
[jQuery] Re: Return key doesn't invoke OK button in JQuery dialog
> For some reason, Return key doesn't invoke OK button in JQuery dialog. > Any idea what could be the issue? Do you have some simple code demonstrating the problem? If the OK button is a submit button in a form this generally should work, but an example would be good.
[jQuery] Re: How to keep two items having the same value
> What I want is: When the user choose an item from the number1 > , the number2 will automatically change to the same > value to the number2. Maybe something like this? $("select[name=number1]").change(function(){ $("select[name=number2]").val( $(this).val() ); }); If the change event doesn't do it for you, take a look at .click() or .blur().
[jQuery] Re: jQuery Tabs -- Long content in hidden tabs
If this is UI Tabs you should ask in the jQuery UI group.
[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
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" 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 > > 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.
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 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.
[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
[jQuery] Append Help
I have a div that I want to add new content to after the div closes original content here original content here
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 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] 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
[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] 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