[jQuery] Re: jQuery 1.3b1 and the Galleria Plug-In
Thats great info... I did the same but in my case the caption text is missing where as the prev/next buttons are ok.
[jQuery] change()
Hello all, a little new the js and jquery any help would be fantastic... I have this in my linked myFx.js file: $(document).ready(function() { var selected_type = $('select#campaign_type_select'); var coupon_div = $('#campaign_create_coupon'); var broadcast_div = $('#campaign_create_broadcast'); var contest_div = $('#campaign_create_contest'); // alert(selected_type.val()); I CAN GET THIS TO FIRE WHEN UNCOMMENTED, and it returns the the value coupon as i would expect. BUT THIS ISNT WORKING ive tried various renditions (this.val(), selected_type, etc...) based on what i have read on this site and the jQuery site with 0 success. selected_type.change(function() { if (this.val() == 'contest') { alert('contest'); } else if (this.val() == 'broadcast') { alert('broadcast'); } else (this.val() == 'coupon') { alert('coupon'); } }); }); This is the HTML: div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div Someone point me in the right direction.\m/.\m/
[jQuery] Re: jQuery 1.3b1 and the Galleria Plug-In
I am wanting to stop receiving these emails, but cannot get in to cancel them. I thought that I cancelled my account, but am still receiving the emails. Any ideas on how to shut this down? Deaven Butler On Jan 2, 2009, at 2:09 AM, Nikola wrote: Thats great info... I did the same but in my case the caption text is missing where as the prev/next buttons are ok.
[jQuery] How can I call a function if I have that function name stored in a string?
Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: Noob Q. Can't get jQuery working
I found and fixed the problem for Wordpress. In the header, I had the inline code: Code: script type=text/javascript var $j = jQuery.noConflict(); $j(function() { $j('#tab-panel1 ul').tabs({ fxFade: true, fxSpeed: 'fast' }); $j('#tab-panel2 ul').tabs({ fxFade: true, fxSpeed: 'fast' }); $j('#container-11 ul').tabs({ event: 'mouseover' }).find ('a').click(function() { return false; }); }); /script This was the cause for crashing the jQuery. Once I wrapped the code in jQuery().ready(function(){ code here }); it worked. I will offcourse move this scrips to a js. file Now for doing the same test with Drupal. Steven On 2 Jan, 02:39, Ricardo Tomasi ricardob...@gmail.com wrote: I think Wordpress loads prototype.js as well, try protecting your jQuery script: jQuery.noConflict()(function(){ $('a').click(... }); On Jan 1, 7:29 pm, spstieng spsti...@hotmail.com wrote: Tha path is correct. I use FireBug to debug the javascript and I can see the jQuery script executing. I was executing this code inside Wordpress CMS and Drupal CMS. To test further, I created a test site tha only contains the index.php It worked perfectly. When debugging I see that it first calls the jQuery when executing this line: $(document).ready(function() { Then I see it use jQuery one more time executing this line: $(a).click(function() { Doing the same debugging in WordPress and Drupal, it only executes the first line, not the second line. Firefox is not giving me any javascript error, bit IE is giving me one, but it makes no sense: Line: 4 Char: 3 Error: Object doesn't support this property or method Code: 0 Url:http://localhost/mysite/test On 1 Jan, 19:28, Matt Quackenbush quackfu...@gmail.com wrote: Probably because the path to jQuery is incorrect and therefore jQuery is not actually loaded. On Thu, Jan 1, 2009 at 5:26 AM, spstieng wrote: Now, clicking Test B links dislays the 'Hello World' alert. But nothing happends when I click Test A. Why is that?
[jQuery] Change the date format of jquery calendar
Hi all i have one jquery calendar $('selector').datePicker(); which is giving me in dd/mm/ i want to change this format to -mm-dd i tried with $.datePicker.setDateFormat('ymd','-'); error: $.datePicker is undefined and tried with this code $(#sd).datepicker.setDateFormat('ymd','-'); error: $(#sd).datepicker.setDateFormat is not a function
[jQuery] Re: jQuery 1.3b1 and the Galleria Plug-In
The image thumbs don't stay active when selected for some reason. I still haven't really dove into Galleria yet as I'm working on some things with Dialog at the moment but I thought I'd mention it... @Deaven Select Edit my membership and choose your notification preferences...
[jQuery] Re: checkboxes, array and $.post
You rock Ricardo! :) Thank you very much. Just one last question. The submit button (#submitButton) doesn't seem to be serialized along with other fields... And I need its value. How would you add it to the post collection? Regards, -jj. On 1 jan, 22:03, Ricardo Tomasi ricardob...@gmail.com wrote: That's what serialize() is for: $(':submit').click(function(){ var data = $(this).parents('form:first').serialize(); // or $('#formID').serialize(); $.post(delete.php, data, function(){ ... }); }); On Jan 1, 8:48 am, jjshell blahblahcoui...@gmail.com wrote: Hi Ricardo, thanks for your reply. I think I must be missing something when it comes to $.post a form in jQuery. It seems too complicated to have to do something like this: $.post(delete.php,{ field1: $(#field1).val(), field2: $(#field2).val(), field3: $(#field3).val(), field4: $(#field4).val(), } Isn't there a way to simply post the whole form, with the whole post collection, to the specified url, without having to specify which field should be collected? That would make dealing with checkboxes much easier... Here's a sample form. How would you submit it? form name=test id=test method=post action=script.php input type=text name=field1 id=field1 value= / input type=text name=field2 id=field2 value= / input type=text name=field3 id=field3 value= / input type=text name=field4 id=field4 value= / input type=checkbox name=city[] class=cities value=1 / input type=checkbox name=city[] class=cities value=2 / input type=checkbox name=city[] class=cities value=3 / input type=checkbox name=city[] class=cities value=4 / input type=checkbox name=city[] class=cities value=5 / Regards, -jj. On 31 déc 2008, 22:56, Ricardo Tomasi ricardob...@gmail.com wrote: Assuming you have unique names: var CheckedIDs = []; $(input.items_id).livequery('click',function(event){ $(input.items_id).each(function() { if (this.checked) { CheckedIDs[this.name] = $(this).attr (value); } else { CheckedIDs[this.name] = null } }); }); Why do you need to store them in an array anyway? The checked ones values will be submitted with the form, and you can access them at anytime with $(:checkbox:checked) On Dec 31, 3:52 pm, jjshell blahblahcoui...@gmail.com wrote: Ok I'm getting closer... And thanks again for your help :) I can manage to have the checked checkboxes added to the CheckedIDs array. However, if I uncheck a checkbox, it is not removed from the array. It's the last little problem I have to solve :) Here's my code: var CheckedIDs = []; $(input.items_id).livequery('click',function(event){ $(input.items_id).each(function() { if(this.checked){CheckedIDs.push($(this).attr(value));} }); //alert('clicked'); }); On 31 déc, 17:33, Joe joseph.is...@gmail.com wrote: I don't believe you are using livequery in the proper way. You're passing an 'each' event, which does not exist here. In theory, you could do the following: $(input.item_id).livequery('foo',function(bar) { alert('nothing happens'); }); In the console, you will see the length of the wrapped set, the number of inputs with class item_id. Check the API again: http://brandonaaron.net/docs/livequery/#api Also, $.each method is similar to a for-loop: http://docs.jquery.com/Core/each That's a start for sure... Cheers. Joe http://www.subprint.com On Dec 31, 9:39 am, jjshell blahblahcoui...@gmail.com wrote: The problem seems to be located around these parts: var CheckedIDs = []; $(input.item_id).livequery('each',function(add) { if (this.checked){ alert('push'); CheckedIDs.push($(this).attr(value)); } }); On 31 déc, 15:26, jjshell blahblahcoui...@gmail.com wrote: Thanks for your reply :) I only get the alert nothing selected though... Tried to go through the code, couldn't find what is wrong... Regards, -jj. On 31 déc, 14:51, MorningZ morni...@gmail.com wrote: Not sure if it's the *best* way, but it works I'd do something like var CheckedIDs = []; $(input.item_id).each(function() { if (this.checked) { CheckedIDs.push($(this).attr(value)); }}); if (CheckedIDs.length == 0) { alert(Nothing selected!);} else { $.post( delete.php, item_ids: CheckedIDs.join(,), function(data) { //Handle the returned results } } delete.php will see a comma delimited string of IDs to delete On Dec 31,
[jQuery] Re: How can I call a function if I have that function name stored in a string?
I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From: yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery (English) group. To post to this group, send email to jquery-en@googlegroups.com To unsubscribe from this group, send email to jquery-en+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-en?hl=en -~--~~~~--~~--~--~---
[jQuery] Re: Invalid Json Primitive
Also, var params = '{wdgtype:1}'; should be var params = {wdgtype:1}; On Jan 1, 11:35 am, tep turkishexpor...@gmail.com wrote: Hello all, I am trying to create a widget within .NET that's why using JSONP. But when i run the code below, i get the error 'Invalid Json Primitive' on client side before calling web service , how can i handle that ? function test2() { var params = '{wdgtype:1}'; $.ajax({ type: POST, url: service.aspx/GetWidget, data: params, // Set Method Params beforeSend: function(xhr) { xhr.setRequestHeader(Content-length, params.length); xhr.setRequestHeader(Content-type, application/json; charset=utf-8);}, contentType: application/json; charset=utf-8, dataType: jsonp, jsonp:onJsonPLoad, success: function(msg) { $(#showyrmwidget).html(msg.d); }, error: function(xhr,msg,e){ alert(xhr.responseText);//Error Callback } }); } function onJsonPLoad(data) { alert(data); } [WebMethod()] public static string GetWidget(string wdgtype) { return test; } Thanks -- View this message in context:http://www.nabble.com/Invalid-Json-Primitive-tp21229536s27240p2122953... Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: parsing xml
jQuery can't really parse xml, only html. But browsers can: http://www.w3schools.com/Xml/xml_parser.asp On Jan 2, 5:22 am, jhm jmay...@gmail.com wrote: jQuery needs a context for find() to work. That worked thanks! The xml file I was really using actually had a context similar. But it also had a header that was causing the problem. It was: ?xml version=1.0 encoding=UTF-8? Any idea why this would break it? Thanks!
[jQuery] Re: change()
In an event callback function such as the one that's called from .change(), 'this' is not a jQuery object. It is a simple DOM element. You need to wrap it in $() to get a jQuery object if you want to use jQuery methods. Or, you can use DOM properties directly. I would also suggest using a $ prefix on a variable that represents a jQuery object. It's a good visual reminder that you can use jQuery methods on that variable. Also, when using an ID selector, it generally isn't necessary to include the tagname, and in fact the code will be faster if you omit it. For example: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $(this).val() ); }); }); Of course, in this particular case, since you already have the select element wrapped in a jQuery object, $select and $(this) (inside the change function) are the same thing, so you could also do: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $select.val() ); }); }); BTW, I highly recommend triggering on both the change event and the keydown event. This gives better usability when someone uses the keyboard: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.bind( 'change keydown', function() { alert( $(this).val() ); }); }); The only thing to watch out for there is that you want to know if the value has actually changed on the keydown or not. This would take care of that: $(document).ready( function() { var $select = $('#campaign_type_select'); var value = $select.val(); alert( value ); $select.bind( 'change keydown', function() { var newvalue = $(this).val(); if( newvalue != value ) { value = newvalue; alert( value ); } }); }); -Mike From: Bob O Hello all, a little new the js and jquery any help would be fantastic... I have this in my linked myFx.js file: $(document).ready(function() { var selected_type = $('select#campaign_type_select'); var coupon_div = $('#campaign_create_coupon'); var broadcast_div = $('#campaign_create_broadcast'); var contest_div = $('#campaign_create_contest'); // alert(selected_type.val()); I CAN GET THIS TO FIRE WHEN UNCOMMENTED, and it returns the the value coupon as i would expect. BUT THIS ISNT WORKING ive tried various renditions (this.val(), selected_type, etc...) based on what i have read on this site and the jQuery site with 0 success. selected_type.change(function() { if (this.val() == 'contest') { alert('contest'); } else if (this.val() == 'broadcast') { alert('broadcast'); } else (this.val() == 'coupon') { alert('coupon'); } }); }); This is the HTML: div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div Someone point me in the right direction.\m/.\m/
[jQuery] Re: .html() only works on original source?
Thanks for that, never done custom events before. Unfortunately, the whole idea of saving in the $input.data() doesn't work - I think this is because It's not technically the same DOM element, it's a new DOM form element, created from the same markup as one that had data attachments. I've attached the info to $(document).data() instead, using the key formId_inputName. Thanks for your help! On Jan 1, 9:30 pm, Ricardo Tomasi ricardob...@gmail.com wrote: You could use custom events: $('#form').bind('hidden',function(){ $(this).children(':input').each(function(){ var t = $(this); t.data('value', t.val() ); });}).bind('visible',function(){ $(this).children(':input').each(function(){ var t = $(this); t.val( t.data('value') ); }); $('#form').hide().trigger('hidden'); $('#form').show().trigger('visible'); there is also a plug-in that implements listeners for all of jQuery's methods, so you could do something like: $('form').bind('hide', function(){ }); $('form').hide(); But I couldn't find it. I think Ariel Fresler was involved with it. In case he's reading this I bet he would be kind enough to provide you with a link :) cheers, - ricardo On Dec 31 2008, 7:43 am, the_woodsman elwood.ca...@gmail.com wrote: Thanks Ricardo, That's along the lines of what I've been working on, althuogh I didn't think to use data() of the actual field, I was putting it in data ('field_name') of the form itself - your way is probably nicer! I was wondering, instead of the each() loop above, is there an event that I could use for when the inputs become visible again?? that way the inputs know to repopulate themselves when they're re-shown... On Dec 31, 5:05 am, Ricardo Tomasi ricardob...@gmail.com wrote: Two issues at play here: 1. the HTML in most browsers doesn't reflect all recent changes done via Javascript 2. the browser only saves form values after a submit What you can do is save the values at the time of removal, and then re- fill it when you put it back. Use the data() function: // removal, store the values var oldform = $('#form').children(':input').each(function(){ var t = $(this); t.data('value', t.val() ); }).end().remove(); //append and fill oldform.appendTo('body').children(':input').each(function(){ var t = $(this); t.val( t.data('value') ); }); - ricardo On Dec 30, 1:39 pm, the_woodsman elwood.ca...@gmail.com wrote: Hi all, I'm trying to save the content of a form into a hidden div, so I can bring it back later. However, I also want to save the user's progress on the form. I thought I could just dump $('#form').html() into the hidden div, but this seems to only remember the original html, no new value attributes exist even after I've entered some text. I tested with something like this: $('body').find(':input').each( function() { alert($(this).attr('name')+: +$(this).val()+, +$(this).attr ('value')); //.val() and .attr(val) are always up to date and consistent alert(+$(this).parent().html()); //inconsistent with .attr(val) above, seems to be the original only } ); An obvious work around would be to iterate through the inputs explicitly setting the value atribute to .val(), which I assume would work, but it seems there must be a more elegant way... Is there something like .liveHtml()? Or another solution? Thanks in advance...
[jQuery] Window.Open code
I am trying to write a code for window.open in jQuery. here is my code: OpenNewWindow = function(strURL, winName, options) { this._settings = $.extend({ toolbar: no, location: no, directories: no, status: no, menubar: no, scrollbars: no, resizable: yes, width: 100, height: 100 }, options || {}); I am now stuck at the below line. Whether I shouyld write as: window.open(strURL, winName, this._settings); or have I to include all the options for this. I also know that jQwery UI's dialog s another alternative for it, but then I need to change my current aspx page for it to get the values back from the dialog. Can ayone guide me as to what can be my OpenNewWindow code look like. Any more ideas for window.open would e highly appreciated.
[jQuery] Re: jQuery UI 1.6rc3 is out
Very good job!! Fantastic!!! Amazing Thank you! Dirceu Barquette 2009/1/1 Nathan Maves nathan.ma...@gmail.com great job guys! is there going to be an easy way to view the source of the new functional demos? On Wed, Dec 31, 2008 at 8:03 PM, Richard D. Worth rdwo...@gmail.comwrote: jQuery UI 1.6 release candidate 3 is out. Blog post: http://blog.jquery.com/2008/12/31/jquery-ui-16rc3-its-getting-really-close/ Demos: http://ui.jquery.com/demos ThemeRoller v2: http://ui.jquery.com/themeroller Development Bundle: http://code.google.com/p/jquery-ui/downloads/detail?name=jquery.ui-1.6rc3.zip Download Builder: http://ui.jquery.com/download A huge thanks to everyone who helped make this release happen. Note: As mentioned on the blog post, the 1.6 final release (scheduled for 1 week after jQuery 1.3) will ship with and require jQuery 1.3. Please help us test this release with 1.3b1. Thanks. - Richard Richard D. Worth http://rdworth.org/
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
Could you post a testpage? Jörn On Fri, Jan 2, 2009 at 3:31 AM, nate tresbordo...@gmail.com wrote: I am using the jQuery Validate plugin with a form in cakePHP. When I click submit the form is validated but not submitted to the server. When I change the form name From user to user1 it submits properly so it seems that once the form is bound to the javascript it stops submitting the data. any thoughts on how I could get this to work?
[jQuery] Re: How to force a child page to open in iframe using jquery
actually , the written javascript directly checks the url of browser nd if it finds a dff , it fires a location.replace command . Plz suggest how can i stop this default behaviour. On Fri, Jan 2, 2009 at 6:51 AM, Ricardo Tomasi ricardob...@gmail.comwrote: If the iframe has access to the parent frame it's on the same domain, then you have access to it right? I think there's nothing you can do to stop that. On Jan 1, 8:24 am, AbhishEk mithuabh...@gmail.com wrote: Hi, I have a WebPage on which i have an iframe inside which i open child pages . In one of the child pages following script is written script type=text/javascript if (self != top) { if (window.location.href.replace) top.location.replace(self.location.href); else top.location.href=self.document.href; } /script Which replaces my original url to its url and my page is gone .. is there any way using jquery that i can stop this page from bursting my iframe. Plz Help. Thanks in advance ~abhi
[jQuery] is it possible to get result of this
Hi I am trying to do something with Jquery and Ajax But I am not sure that its possible or not. its my example, you can see what I am trying to do. http://www.unikhas.org/design/index.jsp I want to save all the things after I desing my tshirt. Is it possible to do that in Jquery or Ajax ? or should I use other technologies? thank you very much..
[jQuery] Re: Change the date format of jquery calendar
What version are you using? Also, more of your code (an entire simplified test page ideally) would help. Also note, there is a dedicated list for questions about jQuery UI plugins[*] http://groups.google.com/group/jquery-ui - Richard [*] http://rdworth.org/blog/2008/10/jquery-plugins-and-jquery-ui/ On Fri, Jan 2, 2009 at 3:44 AM, Praveen praveen.python.pl...@gmail.comwrote: Hi all i have one jquery calendar $('selector').datePicker(); which is giving me in dd/mm/ i want to change this format to -mm-dd i tried with $.datePicker.setDateFormat('ymd','-'); error: $.datePicker is undefined and tried with this code $(#sd).datepicker.setDateFormat('ymd','-'); error: $(#sd).datepicker.setDateFormat is not a function
[jQuery] Re: form plugin and blockUI problems in IE7 with the ui not unblocking
I found the problem, it was an extra form tag that I had on the page nested in my other form tag. I copied and pasted in code for paging from the table sorter plugin and never removed the form tag from the example. Once I removed that it worked great. Thanks for your response. I have to say that this is one of the best maintained boards and software projects I have worked with. I have gotten some fast responses here and appreciate everyone's help. JQuery is really cool! Jonathan On Jan 1, 10:18 pm, Mike Alsup mal...@gmail.com wrote: I'm using the form plugin and the most recent version of blockUI. Here's my form initialization area: $(document).ready(function() { var options = { target: '#search_results', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse // post-submit callback }; // bind to the form's submit event $('#search_form').submit(function() { $.blockUI(); $(this).ajaxSubmit(options); return false; }); }); And then here is my post submit callback function // post-submit callback function showResponse(responseText, statusText) { // add sorter. $(#myTable).tablesorter({sortList:[[0,0],[2,1]], widgets: ['zebra']}); $(#options).tablesorter({sortList: [[0,0]], headers: { 3:{sorter: false}, 4:{sorter: false}}}); // add pager. $(#myTable).tablesorterPager({container: $(#pager)}); $(#pager).show(); $.unblockUI(); } All this works ok in Firefox but in IE, blockUI does not unblock. I don't get any javascript errors and it seems like the call should go through ok. Any ideas? Is all the other code in the showResponse function executing? Can you provide a link? I put together a quick test which seems to work fine: http://www.malsup.com/jquery/block/ie7-form-test.html Mike
[jQuery] Re: Autocomplete plugin rare behaviour
Ok, this is my script and the piece of html that is related to it. The HTML: ... input autocomplete=off id=productname name=productname value=Televisión LCD LG 42 pulgadas 42LG3000 class=value big ac_input type=text ... The JS code: $(#productname) .autocomplete(ax/suggest.html, { minChars: 2, max: 10, scroll: false, matchContains: true, formatResult: function(data, value) { return value.split('|')[0]; }, extraParams: { type: 'product'} }); Regards!
[jQuery] Live Search
Hello Sometimes I hav problems with exscale.se's live search tool. When I integrate it to my site IE7 cannot load the webpage with the live search tool? Does someone have a clue or an other livesearch Tool? Greetings Simon
[jQuery] Jquery coding direction
I'm having problems wrapping my head around how to code this: I have two textboxes both are required. However if a user fills out one of the textboxes then the other is no longer required. Any suggestions? Thanks Tom
[jQuery] Re: is it possible to get result of this
Well, it all depends how you're intending to save the shirt customisations in the back end! Assuming you're saving some list of images for shirts (along with their positions) in your database, there's no reason this couldn't be done via ajax. I'd advise, however, making this save in a traditional full page load for now - it's not usually that difficult to ajaxify something that's already working, and will make the task at hand a lot clearer and more focussed. On Jan 2, 11:36 am, merihsaka...@yahoo.com merihsaka...@yahoo.com wrote: Hi I am trying to do something with Jquery and Ajax But I am not sure that its possible or not. its my example, you can see what I am trying to do.http://www.unikhas.org/design/index.jsp I want to save all the things after I desing my tshirt. Is it possible to do that in Jquery or Ajax ? or should I use other technologies? thank you very much..
[jQuery] Where is syntax error ?
Hi! I want to reuse examples of http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/ for an accordion. Here is Html code: div class=accordion ul li h3Question One Sample Text/h3 ul liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula./li /ul /li li h3This is Question Two/h3 ul liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula./li /ul /li li h3Another Questio here/h3 ul liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula./li /ul /li li h3Sample heading/h3 ul liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula./li /ul /li li h3Sample Question Heading/h3 ul liLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula./li /ul /li /ul Here is my custom accordion code wich doesn't work: script type=text/javascript $(document).ready(function(){ $(.accordion ul li h3:first).addClass(active); $(.accordion ul li ul li:not(:first)).hide(); $(.accordion ul li h3).click(function(){ $(this).next(ul li).slideToggle(slow) .siblings(ul li:visible).slideUp(slow); $(this).toggleClass(active); $(this).siblings(ul li h3).removeClass(active); }); }); /script I don't see errors... :) Thanks for your help! B.I.
[jQuery] IE7: Setting ColSpan as Attribute
This had me scratching my head for a while, so I wanted to share it in case it might help someone else: It seems that using JQuery's attr() function to set a table cell's colspan attribute does not always work properly. Sometimes although the attribute is set properly in the DOM (which can be verified if you read the colspan attribute with attr), IE still renders the cell as only 1 column wide instead of the colspan value. What seems to work best is something like this: $(jQueryTableCells).each(function() { this.colSpan = someValue; }); The JavaScript implementation of colSpan seems to work fine. Looks like a problem with IE's implementation of the DOM rather than with JQuery, but I couldn't find it documented anywhere, so I wanted to post it here. -Nate
[jQuery] jquery skilled coder(s) needed for project
Hello, Looking to outsource a project that entails heavy jquery work for home page for a site thats based on Drupal (D5) CMS. Any candidates that could get involved with the project immediately or even maybe have a team that can handle it as time release is critical, please email me personally for further details. Thank you, George
[jQuery] Form manipulation - Advanced
I'm new to jquery but I have no idea how to do this. Any help would be greatly appreciated and would lead down the correct path. Thank you in advance. There's 2 sections in my form. 1) Vehicle Makes Basically, I want the user to be able to enter their make if it's not in the list. Once the user enters their make I would like it displayed right under the list. ( would be great if user can delete the make they just entered ) 2) Vehicle Features Basically, I want the user to be able to enter a feature if it's not in the list. The entered feature should display at the end of the list. User can enter many features. ( would be great if user can delete the feature they just entered ) Here's the form: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN html head titleTest/title /head body Section 1) table width=100% border=0 tr tdMake/td tdEnter your make ( if not in the list ) /td /tr tr td width=22%input name=make type=radio value=Honda Honda/td td width=58%input type=text name=textfield input type=submit name=Submit value=Submit/td /tr tr tdinput name=make type=radio value=Toyota Toyota/td tdnbsp;/td /tr tr tdinput name=make type=radio value=Mazda Mazda/td tdnbsp;/td /tr /table Section 2) table width=100% border=0 tr tdSelect features that apply to your vehicle. /td tdEnter another ( if not in the list ) /td /tr tr td width=22%input name=feature type=checkbox id=feature value=ac A/C/td td width=58%input type=text name=textfield2 input type=submit name=Submit2 value=Submit/td /tr tr tdinput name=feature type=checkbox id=feature value=auto Automatic/td tdnbsp;/td /tr tr tdinput name=feature type=checkbox id=feature value=pw Power Windows /td tdnbsp;/td /tr /table /body /html
[jQuery] How to set the HTML background
I want to be able to change the background of the page, I can successfully do $(document.body).css(background, yellow); but I have two separate css backgrounds, one sets the body tag and one sets the html tag. So how do I set the html tags background I've tried $(document.html).css(background, yellow); but it won't work :/ -- View this message in context: http://www.nabble.com/How-to-set-the-HTML-background-tp21252706s27240p21252706.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: JQUERY .POST PROBLEM
Anyone have any ideals why when the if statement is being by-passed?
[jQuery] Re: jQuery UI Tabs (Selected tab item)
You may want to ask on the jQuery UI mailing list: http://groups.google.com/group/jquery-ui which is a dedicated list for questions about jQuery UI plugins[*], in case your question was missed here. - Richard [*] http://rdworth.org/blog/2008/10/jquery-plugins-and-jquery-ui/ On Fri, Dec 19, 2008 at 4:35 PM, 01Kuzma 01ku...@gmail.com wrote: Hi all! Currently I haven't coded JS, so I don't know how to solve my problem. So, I'm using jQuery UI Tabs (http://stilbuero.de/jquery/tabs_3/) and I encountered with problem. I need to get an ID or something else of currently selected tab and send it to PHP. The code is: script src=../tabs/jquery-1.1.3.1.pack.js type=text/javascript/ script script src=../tabs/jquery.history_remote.pack.js type=text/ javascript/script script src=../tabs/jquery.tabs.pack.js type=text/ javascript/script script type=text/javascript $(function() { $('#container-5').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'normal' }); }); /script link rel=stylesheet href=../tabs/jquery.tabs.css type=text/css media=print, projection, screen div id=container-5 ul lia href=#fragment-1span123/span/a/li lia href=#fragment-2span456/span/a/li lia href=#fragment-3span789/span/a/li lia href=#fragment-4span000/span/a/li /ul div id=fragment-1 adasd /div div id=fragment-2 ? include_once('123_ru.php'); ? /div div id=fragment-3 ? include_once('456_ru.php'); ? /div div id=fragment-4 ? include_once('789_ru.php'); ? /div /div The main problem is, that all php files are loaded simultaneously, but i need that they load only when i press on a current tab. In documentation I've found and JS code : var $tabs = $('#example').tabs(); var selected = $tabs.data('selected.tabs'); but I don't understand how to use it. Thank you !
[jQuery] Re: firebug regression: console.log($('div')) less useful
It's a Firebug change. Use console.dir() instead (but I agree--I like the old console.log() method) On Fri, Jan 2, 2009 at 1:10 AM, Danny d.wac...@prodigy.net wrote: Has anyone else noticed that Firebug before 1.2 would treat console.log ($('div')) as an array and list all the matched elements on the console, so you could mouse over the list and highlight the elements, or right-click and scroll into view etc., but now it just lists Object length=13 and you need to click on that, then you get a vertical list that you need to scroll through. The old way was more helpful, I think. John Resig, you're the Mozilla Firebug person as well as the jQuery Man; can this be fixed? Workaround: console.log.apply(console, $('div').get()) comes close to reproducing the old behavior. I'll crosspost this on the Firebug list.
[jQuery] Re: Submit not propagating.
Anyone have an idea? On Dec 30 2008, 4:25 pm, TimW66 timwilso...@gmail.com wrote: Hi all, I have a submit button, and a function tied to it via $('form').submit (function() { ... }); When the button is clicked, this function gets executed, and the data gets sent to the server. However, I also call this function via a context menu option (i.e., $('form').submit()). Again, the function gets executed, but the data does not get sent to the server. I added return true; as the last line of the submit function, but that didn't seem to help. Running the code through Firebug, I noticed on line 2078 of jquery-1.2.6.js, there's a comparison val !== false. When the button is clicked, this comparison succeeds, and val is set to ret. However, when I call the function from the context menu, this comparison fails, and val is left as undefined. My question is, what's causing the difference? Should I be doing something different? I've also tried $('form').trigger('submit'), and $('#submit').click(). Neither work. The last one appears to do something completely different than what I expected. My submit button's html is: input type=submit id=submit name=submit value=save / Here's my function: $('form').submit(function() { clearEmptyRows(); $('tr.deleted td:first-child input').each(function() { if( !$(this).hasClass('KeyField') ) return; $('form').append('input type=hidden value=' + this.value + ' name=deleted/'); }); return true; }); And the call from the context menu function: $('form').submit(); What I need is a Save option from the context menu (and eventually, a top menu), that does the same thing as the button does. At some point, we may remove the save button from the screen (or if necessary, just hide it), so we'll need some way to submit the form. Any help would be greatly appreciated.
[jQuery] Re: change()
I must not be getting it, this is whati have now, and it is still not working as needed. $(document).ready(function() { var $select = $('select#campaign_type_select'); var $value = $select.val(); var $coupon_div = $('#campaign_create_coupon'); var $broadcast_div = $('#campaign_create_broadcast'); var $contest_div = $('#campaign_create_contest'); $select.bind( 'change keydown', function() { if ($(this).val() == 'contest') { alert('contest'); $coupon_div.show(); $broadcast_div.hide(); $contest_div.hide(); } else if ($(this).val() == 'broadcast') { alert('broadcast'); $coupon_div.hide(); $broadcast_div.show(); $contest_div.hide(); } else ($(this).val() == 'coupon') { alert('coupon'); $coupon_div.hide(); $broadcast_div.hide(); $contest_div.show(); } }); }); HTML - div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div On Jan 2, 2:48 am, Michael Geary m...@mg.to wrote: In an event callback function such as the one that's called from .change(), 'this' is not a jQuery object. It is a simple DOM element. You need to wrap it in $() to get a jQuery object if you want to use jQuery methods. Or, you can use DOM properties directly. I would also suggest using a $ prefix on a variable that represents a jQuery object. It's a good visual reminder that you can use jQuery methods on that variable. Also, when using an ID selector, it generally isn't necessary to include the tagname, and in fact the code will be faster if you omit it. For example: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $(this).val() ); }); }); Of course, in this particular case, since you already have the select element wrapped in a jQuery object, $select and $(this) (inside the change function) are the same thing, so you could also do: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $select.val() ); }); }); BTW, I highly recommend triggering on both the change event and the keydown event. This gives better usability when someone uses the keyboard: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.bind( 'change keydown', function() { alert( $(this).val() ); }); }); The only thing to watch out for there is that you want to know if the value has actually changed on the keydown or not. This would take care of that: $(document).ready( function() { var $select = $('#campaign_type_select'); var value = $select.val(); alert( value ); $select.bind( 'change keydown', function() { var newvalue = $(this).val(); if( newvalue != value ) { value = newvalue; alert( value ); } }); }); -Mike From: Bob O Hello all, a little new the js and jquery any help would be fantastic... I have this in my linked myFx.js file: $(document).ready(function() { var selected_type = $('select#campaign_type_select'); var coupon_div = $('#campaign_create_coupon'); var broadcast_div = $('#campaign_create_broadcast'); var contest_div = $('#campaign_create_contest'); // alert(selected_type.val()); I CAN GET THIS TO FIRE WHEN UNCOMMENTED, and it returns the the value coupon as i would expect. BUT THIS ISNT WORKING ive tried various renditions (this.val(), selected_type, etc...) based on what i have read on this site and the jQuery site with 0 success. selected_type.change(function() { if (this.val() == 'contest') { alert('contest'); } else if (this.val() == 'broadcast') { alert('broadcast'); } else (this.val() == 'coupon') { alert('coupon'); } }); }); This is the HTML: div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div Someone point me in the right direction.\m/.\m/
[jQuery] Re: How to set the HTML background
That's because you can't set the background color of the HTML tag. It doesn't have that attribute. Even if you could do that, one would override the other. What you probably want to do is to set the bg of the body tag, then set the bg of a container INSIDE the body like so: body div/div /body -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of BlueStunt Sent: Friday, January 02, 2009 9:29 AM To: jquery-en@googlegroups.com Subject: [jQuery] How to set the HTML background I want to be able to change the background of the page, I can successfully do $(document.body).css(background, yellow); but I have two separate css backgrounds, one sets the body tag and one sets the html tag. So how do I set the html tags background I've tried $(document.html).css(background, yellow); but it won't work :/ -- View this message in context: http://www.nabble.com/How-to-set-the-HTML-background-tp21252706s27240p212527 06.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: Submit not propagating.
I have a suspicion...give the button a name other than submit. http://jibbering.com/faq/names/
[jQuery] Re: firebug regression: console.log($('div')) less useful
Thanks; I didn't know about console.dir(). My workaround puts it on fewer lines, without all the jQuery plugins, so it's more useful. On Jan 2, 9:59 am, Dan G. Switzer, II dswit...@pengoworks.com wrote: It's a Firebug change. Use console.dir() instead (but I agree--I like the old console.log() method) On Fri, Jan 2, 2009 at 1:10 AM, Danny d.wac...@prodigy.net wrote: Has anyone else noticed that Firebug before 1.2 would treat console.log ($('div')) as an array and list all the matched elements on the console, so you could mouse over the list and highlight the elements, or right-click and scroll into view etc., but now it just lists Object length=13 and you need to click on that, then you get a vertical list that you need to scroll through. The old way was more helpful, I think. John Resig, you're the Mozilla Firebug person as well as the jQuery Man; can this be fixed? Workaround: console.log.apply(console, $('div').get()) comes close to reproducing the old behavior. I'll crosspost this on the Firebug list.
[jQuery] Re: How can I call a function if I have that function name stored in a string?
Thanks Mike, I'm following this tutorial here: http://www.learningjquery.com/2007/10/a-plugin-development-pattern I have several public functions like this: $.fn.response.redirect.default = function (){//something here}; $.fn.response.redirect.type1 = function (){//something here}; $.fn.response.redirect.type2 = function (){//something here}; I wanted to be able to call the appropriate function depending on a string passed back to me via json Im thinking of doing it like this (based on your example): if($.fn.response.redirect[response.redirect_type] !== undefined) $.fn.response.redirect[response.redirect_type](); else $.fn.response.redirect.default(); Do you think it would work? Thanks again for your help Raine On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From:yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: Submit not propagating.
Thanks for the response. I changed the name attribute to be save, but that didn't work either. I think what's happening is there are other event handlers getting executed in the for loop, and one of those is returning a value that val gets set to, such that it doesn't propagate to the next function; which in my case is the browser submit. Of course, I have no idea which event handler is returning a value that is causing val to get set that way. On Jan 2, 10:21 am, Dave Methvin dave.meth...@gmail.com wrote: I have a suspicion...give the button a name other than submit. http://jibbering.com/faq/names/
[jQuery] script and strange behaviours with ie
hello, I was sure that my script failed the ie execution test. IE7: activex and script check block the script, then allow and it works. IE6: it works IE5.5: my script waits the image loading with a animated gif, than show the images. This ie waits without end or errors. IE5, IE4: raise two errors on page loading. (I'm italian, try to translate the errors) ... first: Quantificator unexpected; second error: character not valid. IE7, IE6: the script works only the first time, with this script i align and resize 12 images on a grid. If I reload the page, one image (always the same image) doesn't resize, and i have to close the browser and reopen it. What can I do to solve these issues? ..in addiction to trash ie :P (The script works fine with Firefox and Safari) thanks max
[jQuery] Re: How can I call a function if I have that function name stored in a string?
I'm just taking a shot in the dark, but have you looked at eval()? I saw this used in a demo page, and thought it was ingenious. The text they want to execute is shown on the screen. The JS gets the text and calls eval() on it. This might get you what you want. On Jan 2, 10:57 am, yellow1912 yellow1...@gmail.com wrote: Thanks Mike, I'm following this tutorial here:http://www.learningjquery.com/2007/10/a-plugin-development-pattern I have several public functions like this: $.fn.response.redirect.default = function (){//something here}; $.fn.response.redirect.type1 = function (){//something here}; $.fn.response.redirect.type2 = function (){//something here}; I wanted to be able to call the appropriate function depending on a string passed back to me via json Im thinking of doing it like this (based on your example): if($.fn.response.redirect[response.redirect_type] !== undefined) $.fn.response.redirect[response.redirect_type](); else $.fn.response.redirect.default(); Do you think it would work? Thanks again for your help Raine On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From:yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: is it possible to get result of this
Thanks alot, I'm trying to get position (coordinate) of the image.. Do you know how can I get their position? Its all code about drag.. link href=buz.css rel=stylesheet type=text/css script type=text/javascript src=js/jquery.js/script script type=text/javascript src=js/iutil.js/script script type=text/javascript src=js/idrag.js/script body div id=parentElem div id=insideParentimg src=images/noelbabayla_big.png/ div /div script type=text/javascript $(document).ready( function() { $('#insideParent').Draggable( { zIndex: 1000, ghosting: false, opacity:0.7, containment : 'parent' } ); } ); /script /body and ajaxify is very usefull.. I'll use it in my poject. :) thank you..
[jQuery] Re: How can I call a function if I have that function name stored in a string?
Yes, Raine, that would certainly work. A couple of notes... First, 'default' is a reserved word in JavaScript. You can use it as a method name if you want, but not using foo.default notation. That may work in some browsers, but you can't count on it working in all of them. You would have to use foo['default'] instead: $.fn.response.redirect['default'] = function (){/*...*/}; $.fn.response.redirect['default'](); Or simply pick a different name that isn't a reserved word. Second, do these public functions care if they are called as methods of the $.fn.response.redirect object? IOW, do they use this and expect it to be a reference to $.fn.response.redirect? If they don't, you can simplify the code a bit: var fn = $.fn.response.redirect[response.redirect_type] || $.fn.response.redirect['default']; fn(); Or even: ( $.fn.response.redirect[response.redirect_type] || $.fn.response.redirect['default'] )(); In fact, if you are providing the response.redirect_type in JSON that you're generating yourself, and you know that it will be either a valid function name or undefined, you could just do: $.fn.response.redirect[ response.redirect_type || 'default' ](); Of course, there's nothing wrong with the code as you've written it (except for the .default part as mentioned), it's just nice to have some options. (I should mention that these bits of code don't work *exactly* the same as yours - you are doing a strict test for undefined, while these use the || operator and therefore just test for any false value which would include undefined, null, false, 0 or .) -Mike From: jquery-en@googlegroups.com Thanks Mike, I'm following this tutorial here: http://www.learningjquery.com/2007/10/a-plugin-development-pattern I have several public functions like this: $.fn.response.redirect.default = function (){//something here}; $.fn.response.redirect.type1 = function (){//something here}; $.fn.response.redirect.type2 = function (){//something here}; I wanted to be able to call the appropriate function depending on a string passed back to me via json Im thinking of doing it like this (based on your example): if($.fn.response.redirect[response.redirect_type] !== undefined) $.fn.response.redirect[response.redirect_type](); else $.fn.response.redirect.default(); Do you think it would work? Thanks again for your help Raine On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From:yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: How can I call a function if I have that function name stored in a string?
Nice trickery there Mike! I dig it! On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From: yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: Submit not propagating.
What is the code for the context menu? I have a hunch it is somewhere in there. Joe On Jan 2, 11:17 am, TimW66 timwilso...@gmail.com wrote: Thanks for the response. I changed the name attribute to be save, but that didn't work either. I think what's happening is there are other event handlers getting executed in the for loop, and one of those is returning a value that val gets set to, such that it doesn't propagate to the next function; which in my case is the browser submit. Of course, I have no idea which event handler is returning a value that is causing val to get set that way. On Jan 2, 10:21 am, Dave Methvin dave.meth...@gmail.com wrote: I have a suspicion...give the button a name other than submit. http://jibbering.com/faq/names/
[jQuery] Re: How can I call a function if I have that function name stored in a string?
Don't thank me, Joe, thank Brendan Eich who developed JavaScript. :-) (But thanks for your comment the other day about the .slowEach plugin... I guess I'll take credit for that one...) -Mike From: Joe Nice trickery there Mike! I dig it! On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From: yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: Jquery coding direction
On Fri, Jan 2, 2009 at 10:16 AM, tawright915 tawright...@gmail.com wrote: I'm having problems wrapping my head around how to code this: I have two textboxes both are required. However if a user fills out one of the textboxes then the other is no longer required. $('#the_form').submit(function() { return $('#textarea_1').val() || $('#textarea_2').val(); }); Obviously, you'd want to adjust that to give some feedback to the user.
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
Jörn, Thanks for your response. I got it to submit with submitHandler: function(form) { form.submit(); }, now I have a problem when using the cakephp form helper. This works with the manually created input rules: { phone: {phoneUS: true} } input name=phone id=phone value=555-555-/ however I am not sure how to setup the rules when using the cakePHP form helper. The helper generates the following: input name=data[UserContactDetail][phone] type=text value=555-555- id=UserContactDetailPhone / I have tried using rules: { data[UserContactDetail][phone]: {phoneUS: true} } and this rules: { UserContactDetailPhone: {phoneUS: true} } but it doesn't validate.
[jQuery] jcarousel jquery-1.1.3.1.pack
Hi! I'm working on a website, I need to get the jcarousel (http:// sorgalla.com/jcarousel/) work with jquery 1.1.3.1 but it simply won't. The main carousel application uses jquery 1.2.3 Does it mean that it won't work on an earlier version? Was it major syntax changes between 1.1.3.1 1.2.3? Thanks for your support. Adame
[jQuery] Re: is it possible to get result of this
Do you know any example of getting new position of dragged image?
[jQuery] Re: Submit not propagating.
The context menu calls the following function (note, this function is called called from a simple ul ... li style of top menu, and the same behavior is observed there): function saveChanges(t, leaveScreen) { $('form').trigger('submit'); if( leaveScreen ) { exitScreen(); } } When the trigger fires, this function is called: $('form').submit(function() { clearEmptyRows(); $('tr.deleted td:first-child input').each(function() { if( !$(this).hasClass('KeyField') ) return; $('form').append('input type=hidden value=' + this.value + ' name=deleted/'); }); return true; }); I've set a breakpoint in Firebug at the return true line, and it does stop there. I've also set a breakpoint in the previous function at the if( leaveScreen ) { line. It stops at that breakpoint too. So I know these 2 functions are getting called. However, I expected the data to be updated in the database, before calling exitScreen(). This does not appear to be the case. It looks like what's happening is the chain of submit functions is stopping at the end of my submit function. So the browser submit function never fires, which means the data is never transmitted to the server. My Tomcat log does not show data getting received by the server, so again, it looks like the browser submit function fires. On Jan 2, 12:15 pm, Joe joseph.is...@gmail.com wrote: What is the code for the context menu? I have a hunch it is somewhere in there. Joe On Jan 2, 11:17 am, TimW66 timwilso...@gmail.com wrote: Thanks for the response. I changed the name attribute to be save, but that didn't work either. I think what's happening is there are other event handlers getting executed in the for loop, and one of those is returning a value that val gets set to, such that it doesn't propagate to the next function; which in my case is the browser submit. Of course, I have no idea which event handler is returning a value that is causing val to get set that way. On Jan 2, 10:21 am, Dave Methvin dave.meth...@gmail.com wrote: I have a suspicion...give the button a name other than submit. http://jibbering.com/faq/names/
[jQuery] Re: Submit not propagating.
On Jan 3, 3:17 am, TimW66 timwilso...@gmail.com wrote: Thanks for the response. I changed the name attribute to be save, but that didn't work either. Change the name and the id, neither should have a value of submit. I think what's happening is there are other event handlers getting executed in the for loop, and one of those is returning a value that val gets set to, such that it doesn't propagate to the next function; which in my case is the browser submit. Of course, I have no idea which event handler is returning a value that is causing val to get set that way. Calling a form's submit method will submit the form, but doesn't create a submit event so the listener isn't called. The only value that matters is the one returned to the handler, only false will stop the form submitting. -- Rob
[jQuery] Adding to a group of Radio buttons
These are the radio buttons on my form input name=make type=radio value=Honda id=radio-a Honda input name=make type=radio value=Toyota id=radio-b Toyota input name=make type=radio value=Mazda id=radio-c Mazda Using jquery how can I add another selection to the list? Something like $label.append('input name=make type=radio value=Ford id=radio- d Ford'); ? I can't figure out the syntax. Any help please. Thanks
[jQuery] Re: JQUERY .POST PROBLEM
The 'if' statement in JavaScript is reliable. If your if( data == 'no' ) is taking the else path, the most likely reason is that the data variable is indeed not equal to no. Even though the console.log showed a value of no, are you sure there isn't a newline at the end? What does console.log(data.length) show? You can also use the Fiddler2 debugging proxy, or the Net tab in Firebug, to see the actual length of the body of the response from the PHP script. My suspicion is that there's an extra newline at the end of your PHP script. Your PHP script actually looks like this, doesn't it? ?php ...your code... ? Depending on the version of PHP, a single newline after the ? may not add a newline to the output, but if there are two newlines after the ? you'll definitely get an extra newline in the output - and it wouldn't necessarily be obvious from looking at the PHP code in a text editor. Remember that anything before the opening ?php or after the closing ? is rendered directly as part of the HTML output. Because of this, best practice in a pure PHP script is to *omit* the closing ?. The language does not require it, and omitting the closing ? insures that you won't get any spurious newlines in your output. If this isn't it, post a link to a test page that demonstrates the problem. -Mike From: wattsup I am having some problems with a jquery script that I am writing. The problem is after I receive the data from the php file jquery seems to skip the if statement. I am logging to console and it is showing yes/ no depends on email address. I am enclosing my scripts in case someone can help me. script src=javascripts/jquery-1.2.6.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.validate.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.corner.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.lightbox.packed.js type=text/ javascript/script $(document).ready(function(){ $(#email).blur(function(){ var post_string = $(this).val(); $(#msgbox).removeClass().addClass('messagebox').text ('Checking...').fadeIn(1000); $.post(php/email.php,{ email_check: post_string} ,function(data){ console.log(data); // show data value in console if(data=='no') { // email not avaiable - Skipping this area $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email address already exists').addClass ('messageboxerror').fadeTo(900,1) }); } else { // email avaiable -- Always gos here no matter what $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email available to register').addClass ('messageboxok').fadeTo(900,1); }); } // end if }); // end post }); // end email blur }); // end doc ready PHP FILE if(isset($_POST['email_check'])) { $email = $_POST['email_check']; require_once('config.inc.php'); require(MYSQL); $result = @mysql_query(SELECT * FROM members WHERE (user_email = '$email')); $row_num = mysql_num_rows($result); if( $row_num 0){ // unavailable to register; $valid = no; }else{ // available to register; $valid = yes; }; echo $valid; mysql_close(); } I have been working on this all day and can not figure out why the data is skipping the if statement. if you have any ideals please let me know.
[jQuery] Re: JQUERY .POST PROBLEM
I'm a fan of this approach: console.log('[' + data.length + ']') andy -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Michael Geary Sent: Friday, January 02, 2009 4:23 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: JQUERY .POST PROBLEM The 'if' statement in JavaScript is reliable. If your if( data == 'no' ) is taking the else path, the most likely reason is that the data variable is indeed not equal to no. Even though the console.log showed a value of no, are you sure there isn't a newline at the end? What does console.log(data.length) show? You can also use the Fiddler2 debugging proxy, or the Net tab in Firebug, to see the actual length of the body of the response from the PHP script. My suspicion is that there's an extra newline at the end of your PHP script. Your PHP script actually looks like this, doesn't it? ?php ...your code... ? Depending on the version of PHP, a single newline after the ? may not add a newline to the output, but if there are two newlines after the ? you'll definitely get an extra newline in the output - and it wouldn't necessarily be obvious from looking at the PHP code in a text editor. Remember that anything before the opening ?php or after the closing ? is rendered directly as part of the HTML output. Because of this, best practice in a pure PHP script is to *omit* the closing ?. The language does not require it, and omitting the closing ? insures that you won't get any spurious newlines in your output. If this isn't it, post a link to a test page that demonstrates the problem. -Mike From: wattsup I am having some problems with a jquery script that I am writing. The problem is after I receive the data from the php file jquery seems to skip the if statement. I am logging to console and it is showing yes/ no depends on email address. I am enclosing my scripts in case someone can help me. script src=javascripts/jquery-1.2.6.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.validate.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.corner.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.lightbox.packed.js type=text/ javascript/script $(document).ready(function(){ $(#email).blur(function(){ var post_string = $(this).val(); $(#msgbox).removeClass().addClass('messagebox').text ('Checking...').fadeIn(1000); $.post(php/email.php,{ email_check: post_string} ,function(data){ console.log(data); // show data value in console if(data=='no') { // email not avaiable - Skipping this area $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email address already exists').addClass ('messageboxerror').fadeTo(900,1) }); } else { // email avaiable -- Always gos here no matter what $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email available to register').addClass ('messageboxok').fadeTo(900,1); }); } // end if }); // end post }); // end email blur }); // end doc ready PHP FILE if(isset($_POST['email_check'])) { $email = $_POST['email_check']; require_once('config.inc.php'); require(MYSQL); $result = @mysql_query(SELECT * FROM members WHERE (user_email = '$email')); $row_num = mysql_num_rows($result); if( $row_num 0){ // unavailable to register; $valid = no; }else{ // available to register; $valid = yes; }; echo $valid; mysql_close(); } I have been working on this all day and can not figure out why the data is skipping the if statement. if you have any ideals please let me know.
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an object datascape which among other things, contains a property storing the mouse position, and a function that uses that property. Inside another method i var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { this.myInterval = setInterval(this.move, 200); }).bind(mouseout, function() { clearInterval(this.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } Yet the script does not work: firebug console points at the setInterval call, saying: useless setInterval call (missing quotes around argument?)http://localhost/prototype/_js/frontend/proto.03.js Line 172 can someone help me / explain what i'm doing wrong ? Thank you, Alexandre PS: to all jquerians: happy 2009 !!
[jQuery] Re: Event callback question
Thats cool thanks Brian and Ricardo for your time. Ricardo that did look really good but it doesn't work for me. jQuery(div.mainLiner div.panel).not(':last') .slideUp(750, function(){ console.log(not last); }).end() .filter(':last') .slideUp(750, function(){ console.log(last); //callback } ); This in FF in my situation this produces in the firebug console: last not last not last Really unusual. This has the same problem that the callback function is not actually being called after the finish of all animations. Cheers, Cam On Fri, Jan 2, 2009 at 7:14 PM, Ricardo Tomasi ricardob...@gmail.comwrote: You're right, that will run the callback once for each element. This is a bit hacky but is the shortest way I could think of: function closeMainPanels(){ jQuery(div.mainLiner div.panel).not(':last').slideUp(750).end() .filter(':last').slideUp(750, function(){ //callback }) }; On Jan 2, 1:15 am, Cam Spiers camspi...@gmail.com wrote: They are all sliding up at the same time, but I was under the impression that your code would call the callback function once for each div.panel that was found. Am I mistaken? (would be really awesome if it does only call once) And if I'm not, I reiterate that I only want the callback function called once, and it needs to be called after all of the panels have finished animation. The reason for this is that I am doing a ajax PUT form submission that updates a Members account and then returns the updated DOM section. Then I replace the old DOM section with the new piece after all of the open panels (which display the content which is about to be replaced) are closed. Cheers. On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi ricardob...@gmail.com wrote: If they are all sliding up at the same time, isn't it simpler to use function closeMainPanels(){ jQuery(div.mainLiner div.panel).slideUp(750, function(){ / *...callback...*/ }); } On Jan 1, 5:53 pm, Cam Spiers camspi...@gmail.com wrote: function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var done = []; var length = panels.length; panels.each(function(){ var panel = jQuery(this); panel.slideUp(750, function(){ if (done.push(panel) == length){ callback(); } }); }); } This is what I ended up using thanks brian. :) Cheers, Cam On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers camspi...@gmail.com wrote: Hey, function closeMainPanels(){ jQuery(div.mainLiner div.panel).each(function(){ jQuery(this).slideUp(750); }); } How can I tell when all panels have finished animation? As I need to call another function when all have finished. Cheers, Cam
[jQuery] Re: JQUERY .POST PROBLEM
Good point. Of course, data.length is a number, so it won't have a newline to worry about anyway. But if you're just displaying the data *string*, the brackets (or choose your favorite delimiter) are an excellent idea: console.log( '[' + data + ']' ); That would make it obvious if data has a newline or other whitespace. -Mike From: Andy Matthews I'm a fan of this approach: console.log('[' + data.length + ']')
[jQuery] Re: Submit not propagating.
I gotta admit, I didn't think this would work, but it did. I thought it didn't matter what the name and/or id of an input box was, as long as the id was unique. Guess I was wrong. Thanks for your help, I would have never thought of that! On Jan 2, 4:01 pm, RobG rg...@iinet.net.au wrote: On Jan 3, 3:17 am, TimW66 timwilso...@gmail.com wrote: Thanks for the response. I changed the name attribute to be save, but that didn't work either. Change the name and the id, neither should have a value of submit. I think what's happening is there are other event handlers getting executed in the for loop, and one of those is returning a value that val gets set to, such that it doesn't propagate to the next function; which in my case is the browser submit. Of course, I have no idea which event handler is returning a value that is causing val to get set that way. Calling a form's submit method will submit the form, but doesn't create a submit event so the listener isn't called. The only value that matters is the one returned to the handler, only false will stop the form submitting. -- Rob
[jQuery] Re: Adding to a group of Radio buttons
Hi Carrajo, W3C HTML specs says: associate a label with a form control. There are two standards ways to makup the label element - explicitly and implicity. See: http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL So, lets rewrite your markup using label implicity: labelinput name=make type=radio value=Honda id=radio-a Honda/label labelinput name=make type=radio value=Toyota id=radio-b Toyota/label labelinput name=make type=radio value=Mazda id=radio-c Mazda/label Now jQuery code to achieve your goal: $('input[name=make]').parent('label:last-child').after(' labelinput name=make type=radio value=Ford id=radio-d Ford/label'); and you are able to insert more inputs the same way: $('input[name=make]').parent('label:last-child').after(' labelinput name=make type=radio value=Chevrolet id=radio-d Chevrolet/label'); Regards, Maurício --- These are the radio buttons on my form input name=make type=radio value=Honda id=radio-a Honda input name=make type=radio value=Toyota id=radio-b Toyota input name=make type=radio value=Mazda id=radio-c Mazda Using jquery how can I add another selection to the list? Something like $label.append('input name=make type=radio value=Ford id=radio- d Ford'); ? I can't figure out the syntax. Any help please. Thanks
[jQuery] Re: JQUERY .POST PROBLEM
This is probably a good reason to make it a habit to return a JSON object, so that the data is not simply a string of characters with the associated ambiguities. I realize this leaves me open to counterarguments of 'it's not a efficient' but really that's a minor worry (to me that is). On Jan 2, 5:23 pm, Michael Geary m...@mg.to wrote: The 'if' statement in JavaScript is reliable. If your if( data == 'no' ) is taking the else path, the most likely reason is that the data variable is indeed not equal to no. Even though the console.log showed a value of no, are you sure there isn't a newline at the end? What does console.log(data.length) show? You can also use the Fiddler2 debugging proxy, or the Net tab in Firebug, to see the actual length of the body of the response from the PHP script. My suspicion is that there's an extra newline at the end of your PHP script. Your PHP script actually looks like this, doesn't it? ?php ...your code... ? Depending on the version of PHP, a single newline after the ? may not add a newline to the output, but if there are two newlines after the ? you'll definitely get an extra newline in the output - and it wouldn't necessarily be obvious from looking at the PHP code in a text editor. Remember that anything before the opening ?php or after the closing ? is rendered directly as part of the HTML output. Because of this, best practice in a pure PHP script is to *omit* the closing ?. The language does not require it, and omitting the closing ? insures that you won't get any spurious newlines in your output. If this isn't it, post a link to a test page that demonstrates the problem. -Mike From: wattsup I am having some problems with a jquery script that I am writing. The problem is after I receive the data from the php file jquery seems to skip the if statement. I am logging to console and it is showing yes/ no depends on email address. I am enclosing my scripts in case someone can help me. script src=javascripts/jquery-1.2.6.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.validate.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.corner.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.lightbox.packed.js type=text/ javascript/script $(document).ready(function(){ $(#email).blur(function(){ var post_string = $(this).val(); $(#msgbox).removeClass().addClass('messagebox').text ('Checking...').fadeIn(1000); $.post(php/email.php,{ email_check: post_string} ,function(data){ console.log(data); // show data value in console if(data=='no') { // email not avaiable - Skipping this area $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email address already exists').addClass ('messageboxerror').fadeTo(900,1) }); } else { // email avaiable -- Always gos here no matter what $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email available to register').addClass ('messageboxok').fadeTo(900,1); }); } // end if }); // end post }); // end email blur }); // end doc ready PHP FILE if(isset($_POST['email_check'])) { $email = $_POST['email_check']; require_once('config.inc.php'); require(MYSQL); $result = @mysql_query(SELECT * FROM members WHERE (user_email = '$email')); $row_num = mysql_num_rows($result); if( $row_num 0){ // unavailable to register; $valid = no; }else{ // available to register; $valid = yes; }; echo $valid; mysql_close(); } I have been working on this all day and can not figure out why the data is skipping the if statement. if you have any ideals please let me know.
[jQuery] Re: is it possible to get result of this
ok. I did it :) I can get the position of the image.. thank you the_woodsman :)
[jQuery] Re: JQUERY .POST PROBLEM
That is an excellent idea; I agree completely. There's nothing inefficient about it either. It also leaves the door open to return additional data without breaking your existing code. { valid:true } { valid:false } Now if you want to add other properties to that data, you don't have to change the code that does an if( json.valid ) test. -Mike From: donb This is probably a good reason to make it a habit to return a JSON object, so that the data is not simply a string of characters with the associated ambiguities. I realize this leaves me open to counterarguments of 'it's not a efficient' but really that's a minor worry (to me that is). On Jan 2, 5:23 pm, Michael Geary m...@mg.to wrote: The 'if' statement in JavaScript is reliable. If your if( data == 'no' ) is taking the else path, the most likely reason is that the data variable is indeed not equal to no. Even though the console.log showed a value of no, are you sure there isn't a newline at the end? What does console.log(data.length) show? You can also use the Fiddler2 debugging proxy, or the Net tab in Firebug, to see the actual length of the body of the response from the PHP script. My suspicion is that there's an extra newline at the end of your PHP script. Your PHP script actually looks like this, doesn't it? ?php ...your code... ? Depending on the version of PHP, a single newline after the ? may not add a newline to the output, but if there are two newlines after the ? you'll definitely get an extra newline in the output - and it wouldn't necessarily be obvious from looking at the PHP code in a text editor. Remember that anything before the opening ?php or after the closing ? is rendered directly as part of the HTML output. Because of this, best practice in a pure PHP script is to *omit* the closing ?. The language does not require it, and omitting the closing ? insures that you won't get any spurious newlines in your output. If this isn't it, post a link to a test page that demonstrates the problem. -Mike From: wattsup I am having some problems with a jquery script that I am writing. The problem is after I receive the data from the php file jquery seems to skip the if statement. I am logging to console and it is showing yes/ no depends on email address. I am enclosing my scripts in case someone can help me. script src=javascripts/jquery-1.2.6.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.validate.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.corner.js type=text/javascript charset=utf-8/script script src=javascripts/jquery.lightbox.packed.js type=text/ javascript/script $(document).ready(function(){ $(#email).blur(function(){ var post_string = $(this).val(); $(#msgbox).removeClass().addClass('messagebox').text ('Checking...').fadeIn(1000); $.post(php/email.php,{ email_check: post_string} ,function(data){ console.log(data); // show data value in console if(data=='no') { // email not avaiable - Skipping this area $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email address already exists').addClass ('messageboxerror').fadeTo(900,1) }); } else { // email avaiable -- Always gos here no matter what $(#msgbox).fadeTo(200,0.1,function(){ $(this).html('email available to register').addClass ('messageboxok').fadeTo(900,1); }); } // end if }); // end post }); // end email blur }); // end doc ready PHP FILE if(isset($_POST['email_check'])) { $email = $_POST['email_check']; require_once('config.inc.php'); require(MYSQL); $result = @mysql_query(SELECT * FROM members WHERE (user_email = '$email')); $row_num = mysql_num_rows($result); if( $row_num 0){ // unavailable to register; $valid = no; }else{ // available to register; $valid = yes; }; echo $valid; mysql_close(); } I have been working on this all day and can not figure out why the data is skipping the if statement. if you have any ideals please let me know.
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
I've always found this bit of code useful: var rescope = function(scope, method){ if(!method){ method = scope; scope = null; } if(typeof method == string){ scope = scope || window; if(!scope[method]){ throw(['method not found']); } return function(){ return scope[method].apply(scope, arguments || []); }; } return !scope ? method : function(){ return method.apply(scope, arguments || []); }; } An example: var myObj = { interval: 1000, count: 0, start: function(){ if(this.timer){ return; } this.timer = setInterval(rescope(this, update), this.interval); }, stop: function(){ clearInterval(this.timer); delete this.timer; }, update: function(){ console.log(++this.count); } }; myObj.start(); Regards, Peter Higgins On Fri, Jan 2, 2009 at 5:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an object datascape which among other things, contains a property storing the mouse position, and a function that uses that property. Inside another method i var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { this.myInterval = setInterval(this.move, 200); }).bind(mouseout, function() { clearInterval(this.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } Yet the script does not work: firebug console points at the setInterval call, saying: useless setInterval call (missing quotes around argument?)http://localhost/prototype/_js/frontend/proto.03.js Line 172 can someone help me / explain what i'm
[jQuery] Re: change()
The else statement doesn't accept a condition. Change 'else' to 'else if' and it should be fine, and start using Firebug for Firefox so you can debug your scripts, or Visual Web Developer for IE. On Jan 2, 2:04 pm, Bob O sngndn...@gmail.com wrote: I must not be getting it, this is whati have now, and it is still not working as needed. $(document).ready(function() { var $select = $('select#campaign_type_select'); var $value = $select.val(); var $coupon_div = $('#campaign_create_coupon'); var $broadcast_div = $('#campaign_create_broadcast'); var $contest_div = $('#campaign_create_contest'); $select.bind( 'change keydown', function() { if ($(this).val() == 'contest') { alert('contest'); $coupon_div.show(); $broadcast_div.hide(); $contest_div.hide(); } else if ($(this).val() == 'broadcast') { alert('broadcast'); $coupon_div.hide(); $broadcast_div.show(); $contest_div.hide(); } else ($(this).val() == 'coupon') { alert('coupon'); $coupon_div.hide(); $broadcast_div.hide(); $contest_div.show(); } }); }); HTML - div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div On Jan 2, 2:48 am, Michael Geary m...@mg.to wrote: In an event callback function such as the one that's called from .change(), 'this' is not a jQuery object. It is a simple DOM element. You need to wrap it in $() to get a jQuery object if you want to use jQuery methods. Or, you can use DOM properties directly. I would also suggest using a $ prefix on a variable that represents a jQuery object. It's a good visual reminder that you can use jQuery methods on that variable. Also, when using an ID selector, it generally isn't necessary to include the tagname, and in fact the code will be faster if you omit it. For example: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $(this).val() ); }); }); Of course, in this particular case, since you already have the select element wrapped in a jQuery object, $select and $(this) (inside the change function) are the same thing, so you could also do: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $select.val() ); }); }); BTW, I highly recommend triggering on both the change event and the keydown event. This gives better usability when someone uses the keyboard: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.bind( 'change keydown', function() { alert( $(this).val() ); }); }); The only thing to watch out for there is that you want to know if the value has actually changed on the keydown or not. This would take care of that: $(document).ready( function() { var $select = $('#campaign_type_select'); var value = $select.val(); alert( value ); $select.bind( 'change keydown', function() { var newvalue = $(this).val(); if( newvalue != value ) { value = newvalue; alert( value ); } }); }); -Mike From: Bob O Hello all, a little new the js and jquery any help would be fantastic... I have this in my linked myFx.js file: $(document).ready(function() { var selected_type = $('select#campaign_type_select'); var coupon_div = $('#campaign_create_coupon'); var broadcast_div = $('#campaign_create_broadcast'); var contest_div = $('#campaign_create_contest'); // alert(selected_type.val()); I CAN GET THIS TO FIRE WHEN UNCOMMENTED, and it returns the the value coupon as i would expect. BUT THIS ISNT WORKING ive tried various renditions (this.val(), selected_type, etc...) based on what i have read on this site and the jQuery site with 0 success. selected_type.change(function() { if (this.val() == 'contest') { alert('contest'); } else if (this.val() == 'broadcast') { alert('broadcast'); } else (this.val() == 'coupon') { alert('coupon'); } }); }); This is the HTML: div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option
[jQuery] Re: script and strange behaviours with ie
Forget browsers older than IE6, they are unsupported by jQuery (and ignored by most web developers). Your problem could be anything, do you have a test page we can take a look at, or some code? I guess it has to do with the ready/load events, as when you reload the page the images are in the browser cache already. On Jan 2, 3:20 pm, Saledan bastil...@gmail.com wrote: hello, I was sure that my script failed the ie execution test. IE7: activex and script check block the script, then allow and it works. IE6: it works IE5.5: my script waits the image loading with a animated gif, than show the images. This ie waits without end or errors. IE5, IE4: raise two errors on page loading. (I'm italian, try to translate the errors) ... first: Quantificator unexpected; second error: character not valid. IE7, IE6: the script works only the first time, with this script i align and resize 12 images on a grid. If I reload the page, one image (always the same image) doesn't resize, and i have to close the browser and reopen it. What can I do to solve these issues? ..in addiction to trash ie :P (The script works fine with Firefox and Safari) thanks max
[jQuery] Re: Event callback question
Strange. In my tests the last element's callback was always called last. jQuery's animations are time-based, that means both animations should end at the same time, with a small offset for the last element at most. Anyway, you already have a solution. I had first rewritten yours before trying the other way, with each() you get the element's index for free. function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var last = panels.length-1; panels.each(function(index){ jQuery(this).slideUp(750, function(){ if (index == last){ callback(); } }); }); } cheers, - ricardo On Jan 2, 8:52 pm, Cam Spiers camspi...@gmail.com wrote: Thats cool thanks Brian and Ricardo for your time. Ricardo that did look really good but it doesn't work for me. jQuery(div.mainLiner div.panel).not(':last') .slideUp(750, function(){ console.log(not last);}).end() .filter(':last') .slideUp(750, function(){ console.log(last); //callback} ); This in FF in my situation this produces in the firebug console: last not last not last Really unusual. This has the same problem that the callback function is not actually being called after the finish of all animations. Cheers, Cam On Fri, Jan 2, 2009 at 7:14 PM, Ricardo Tomasi ricardob...@gmail.comwrote: You're right, that will run the callback once for each element. This is a bit hacky but is the shortest way I could think of: function closeMainPanels(){ jQuery(div.mainLiner div.panel).not(':last').slideUp(750).end() .filter(':last').slideUp(750, function(){ //callback }) }; On Jan 2, 1:15 am, Cam Spiers camspi...@gmail.com wrote: They are all sliding up at the same time, but I was under the impression that your code would call the callback function once for each div.panel that was found. Am I mistaken? (would be really awesome if it does only call once) And if I'm not, I reiterate that I only want the callback function called once, and it needs to be called after all of the panels have finished animation. The reason for this is that I am doing a ajax PUT form submission that updates a Members account and then returns the updated DOM section. Then I replace the old DOM section with the new piece after all of the open panels (which display the content which is about to be replaced) are closed. Cheers. On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi ricardob...@gmail.com wrote: If they are all sliding up at the same time, isn't it simpler to use function closeMainPanels(){ jQuery(div.mainLiner div.panel).slideUp(750, function(){ / *...callback...*/ }); } On Jan 1, 5:53 pm, Cam Spiers camspi...@gmail.com wrote: function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var done = []; var length = panels.length; panels.each(function(){ var panel = jQuery(this); panel.slideUp(750, function(){ if (done.push(panel) == length){ callback(); } }); }); } This is what I ended up using thanks brian. :) Cheers, Cam On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers camspi...@gmail.com wrote: Hey, function closeMainPanels(){ jQuery(div.mainLiner div.panel).each(function(){ jQuery(this).slideUp(750); }); } How can I tell when all panels have finished animation? As I need to call another function when all have finished. Cheers, Cam
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
On Fri, Jan 2, 2009 at 2:32 PM, nate tresbordo...@gmail.com wrote: Jörn, Thanks for your response. I got it to submit with submitHandler: function(form) { form.submit(); }, now I have a problem when using the cakephp form helper. This works with the manually created input rules: { phone: {phoneUS: true} } input name=phone id=phone value=555-555-/ however I am not sure how to setup the rules when using the cakePHP form helper. The helper generates the following: input name=data[UserContactDetail][phone] type=text value=555-555- id=UserContactDetailPhone / I have tried using rules: { data[UserContactDetail][phone]: {phoneUS: true} } and this rules: { UserContactDetailPhone: {phoneUS: true} } but it doesn't validate. Nate, I don't know if my previous msg was sent--gmail's acting a bit screwy. Try putting quotes around the element name: 'data[UserContactDetail][phone]': {phoneUS: true} Validate uses the name as a key in its rules hash, so I can't see it working without quotes. (I haven't yet used Validate with Cake's FormHelper) I can confirm that jQuery can find the element with: $('input[name=data[UserContactDetail][phone]]') I'm not clear on exactly how Validate gets the element, though. That code rivals some of Cake's more ... difficult classes ;-)
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an object datascape which among other things, contains a property storing the mouse position, and a function that uses that property. Inside another method i var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { this.myInterval = setInterval(this.move, 200); }).bind(mouseout, function() { clearInterval(this.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } Yet the script does not work: firebug console points at the setInterval call, saying: useless setInterval call (missing quotes around argument?)http://localhost/prototype/_js/frontend/proto.03.js Line 172 can someone help me / explain what i'm doing wrong ? Thank you, Alexandre PS: to all jquerians: happy 2009 !!
[jQuery] Re: Absolute Image location
On Fri, Jan 2, 2009 at 5:26 PM, MarkAtHarvest m...@harvestinfotech.com wrote: I am trying to run a javascript for a dropdown menu, I need to access the down.gif from images/down.gif , I have two links from where I need to include this javascript one link is in index.jsp in root folder and other is /admin/list.jsp. Now the question is if I access the images with location images/down.gif, I can access it from my index.jsp which is in root folder but my admin/list.gsp is able to access these images. How do I specify the absolute path, so from any level my javascript can access the images. I tried /images/down.gif but that does not work /images/down.gif should work from anywhere if the images directory is at root, unless you've got some rewrite thing going on with stuff that's in /admin. Anyway, you might be better off leaving the img path to your CSS (either relative to root, or the stylesheet) and toggle the image in JS with a classname.
[jQuery] Re: Event callback question
Interesting I have figured out the reason why your example didn't work(and now does). It doesn't work when you have elements in the array which don't need animation/are in the same state initially as the final animation state. So I now have an active class indicating it's state and the selector I use is now 'div.mainLiner div.active' Thanks a lot for your help. This thread is now solved. Cheers, Cam On Sat, Jan 3, 2009 at 1:18 PM, Ricardo Tomasi ricardob...@gmail.comwrote: Strange. In my tests the last element's callback was always called last. jQuery's animations are time-based, that means both animations should end at the same time, with a small offset for the last element at most. Anyway, you already have a solution. I had first rewritten yours before trying the other way, with each() you get the element's index for free. function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var last = panels.length-1; panels.each(function(index){ jQuery(this).slideUp(750, function(){ if (index == last){ callback(); } }); }); } cheers, - ricardo On Jan 2, 8:52 pm, Cam Spiers camspi...@gmail.com wrote: Thats cool thanks Brian and Ricardo for your time. Ricardo that did look really good but it doesn't work for me. jQuery(div.mainLiner div.panel).not(':last') .slideUp(750, function(){ console.log(not last);}).end() .filter(':last') .slideUp(750, function(){ console.log(last); //callback} ); This in FF in my situation this produces in the firebug console: last not last not last Really unusual. This has the same problem that the callback function is not actually being called after the finish of all animations. Cheers, Cam On Fri, Jan 2, 2009 at 7:14 PM, Ricardo Tomasi ricardob...@gmail.com wrote: You're right, that will run the callback once for each element. This is a bit hacky but is the shortest way I could think of: function closeMainPanels(){ jQuery(div.mainLiner div.panel).not(':last').slideUp(750).end() .filter(':last').slideUp(750, function(){ //callback }) }; On Jan 2, 1:15 am, Cam Spiers camspi...@gmail.com wrote: They are all sliding up at the same time, but I was under the impression that your code would call the callback function once for each div.panel that was found. Am I mistaken? (would be really awesome if it does only call once) And if I'm not, I reiterate that I only want the callback function called once, and it needs to be called after all of the panels have finished animation. The reason for this is that I am doing a ajax PUT form submission that updates a Members account and then returns the updated DOM section. Then I replace the old DOM section with the new piece after all of the open panels (which display the content which is about to be replaced) are closed. Cheers. On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi ricardob...@gmail.com wrote: If they are all sliding up at the same time, isn't it simpler to use function closeMainPanels(){ jQuery(div.mainLiner div.panel).slideUp(750, function(){ / *...callback...*/ }); } On Jan 1, 5:53 pm, Cam Spiers camspi...@gmail.com wrote: function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var done = []; var length = panels.length; panels.each(function(){ var panel = jQuery(this); panel.slideUp(750, function(){ if (done.push(panel) == length){ callback(); } }); }); } This is what I ended up using thanks brian. :) Cheers, Cam On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers camspi...@gmail.com wrote: Hey, function closeMainPanels(){ jQuery(div.mainLiner div.panel).each(function(){ jQuery(this).slideUp(750); }); } How can I tell when all panels have finished animation? As I need to call another function when all have finished. Cheers, Cam
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
Brian thanks for the tip. I tried both single and double quotes but that didn't work.
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Here is your orig snippet rewritten to use the rescope function I pasted: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', rescope(this, function(e) { this.mouseX = e.pageX; })).bind(mouseover, rescope(this, function() { this.myInterval = setInterval(rescope(this, move), 200); })).bind(mouseout, rescope(this, function() { clearInterval(this.myInterval); })); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } Though I didn't test it ... You are calling window.datascape.move still in the window scope, when you want the scope (this) to be retained throughout your function calls. Saving a ref to it (var self = this) and accessing it in a function is still the solution. rescope is just that wrapped in a function for sugar (more or less). By passing 'this' to the rescope() function, you are effectively doing the same as self = this; function(){ self.foo(); } .. I find it much cleaner (the non-stripped version of rescope() allows for passing an ambigious number of parameters to the rescope'd function) and easier to work with when I'm explicitly setting the execution scope. Regards, Peter Higgins On Fri, Jan 2, 2009 at 8:06 PM, Alexandre Plennevaux aplennev...@gmail.com wrote: Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an object datascape which among other things, contains a property storing the mouse position, and a function that uses that property. Inside
[jQuery] Re: How can I call a function if I have that function name stored in a string?
Hi Mike, I can't thank you enough for taking your time to teach this newbie how to do it right. I really appreciate your help Sincerely Raine On Jan 2, 12:40 pm, Michael Geary m...@mg.to wrote: Don't thank me, Joe, thank Brendan Eich who developed JavaScript. :-) (But thanks for your comment the other day about the .slowEach plugin... I guess I'll take credit for that one...) -Mike From: Joe Nice trickery there Mike! I dig it! On Jan 2, 3:34 am, Michael Geary m...@mg.to wrote: I don't know about the $.fn.myplugin part - that's not how you would typically call a plugin function in the first place. But in general, given any object 'foo' and any property 'bar', you can reference the 'bar' property in either of two ways: foo.bar Or: foo['bar'] If 'bar' is a method, you can call it with: foo.bar(...); Or: foo['bar'](...); Either one means exactly the same thing. One common use for this is with show and hide methods. Instead of coding: if( doShow ) $('#foo').show(); else $('#foo').hide(); You can code: $('#foo')[ doShow ? 'show' : 'hide' ](); -Mike From:yellow1912 Something like this var func = 'myFunc'; Can I call the function like this for example: $.fn.myplugin.(func)(); (I'm using this in a plugin I'm working on) Thank you very much
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
Got it working with data[UserContactDetail][phone]: {phoneUS: true} and instead of using echo $form-input('phone'); to generate the code I manually typed input name=data[UserContactDetail][phone] /. I am unsure as to why the auto generated field doesn't work since it looks the same to me.
[jQuery] Re: jQuery Validate plugin with cake php form won't submit
On Fri, Jan 2, 2009 at 8:19 PM, nate tresbordo...@gmail.com wrote: Brian thanks for the tip. I tried both single and double quotes but that didn't work. hmmm ... I just found this in the docs: http://docs.jquery.com/Plugins/Validation/Reference#Fields_with_complex_names_.28brackets.2C_dots.29 Did you also use addMethod(phoneUS, ... ?
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Thanks, Alexandre, it's kind of you to say that. About this code... datascape.myInterval = setInterval(window.datascape.move,400); Let's break it down a little. It's exactly the same as doing: var callback = window.datascape.move; datascape.myInterval = setInterval( callback, 400 ); As you can see from this code, JavaScript doesn't remember that the callback function was a property of the datascape object. When you get a reference to the function, that's all you get, a reference to the function itself, without any information about what object the function may have been a method of. So when setInterval calls the function later, it just calls it as a plain old function, and this is the global/window object. Doesn't ActionScript work the same way? It may have a different global object, but I thought most of the JavaScript semantics were similar except for the ActionScript extensions. I haven't worked with ActionScript so I don't know. -Mike From: Alexandre Plennevaux Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an object datascape which among other things, contains a property storing the mouse position, and a function that uses that property. Inside another method i var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX;
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Thanks a lot Peter, that function is really neat ! On Sat, Jan 3, 2009 at 2:25 AM, pete higgins phigg...@gmail.com wrote: Here is your orig snippet rewritten to use the rescope function I pasted: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ $('#datascape').bind('mousemove', rescope(this, function(e) { this.mouseX = e.pageX; })).bind(mouseover, rescope(this, function() { this.myInterval = setInterval(rescope(this, move), 200); })).bind(mouseout, rescope(this, function() { clearInterval(this.myInterval); })); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } Though I didn't test it ... You are calling window.datascape.move still in the window scope, when you want the scope (this) to be retained throughout your function calls. Saving a ref to it (var self = this) and accessing it in a function is still the solution. rescope is just that wrapped in a function for sugar (more or less). By passing 'this' to the rescope() function, you are effectively doing the same as self = this; function(){ self.foo(); } .. I find it much cleaner (the non-stripped version of rescope() allows for passing an ambigious number of parameters to the rescope'd function) and easier to work with when I'm explicitly setting the execution scope. Regards, Peter Higgins On Fri, Jan 2, 2009 at 8:06 PM, Alexandre Plennevaux aplennev...@gmail.com wrote: Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval = setInterval(function() { thisObj.move(); }, 1000); // -- use the vairable referencing the instance }).bind(mouseout, function() { clearInterval(datascape.myInterval); }); }, 'move': function(){ $.log('datascape.move : mouseX = ' + this.mouseX); } } On Thu, Jan 1, 2009 at 3:46 PM, donb falconwatc...@comcast.net wrote: You should change 'move' to move (remove apostrophes). On Jan 1, 9:01 am, Alexandre Plennevaux aplennev...@gmail.com wrote: Hello mates, i have an
[jQuery] Re: How to set the HTML background
That's not true. You can set the html element's background... html { background: yellow; } The reason it doesn't work here is that there is no document.html property. You either can reference the element via document.documentElement or just via html selector: $(html).css(background, yellow); --Klaus On 2 Jan., 17:16, Andy Matthews li...@commadelimited.com wrote: That's because you can't set the background color of the HTML tag. It doesn't have that attribute. Even if you could do that, one would override the other. What you probably want to do is to set the bg of the body tag, then set the bg of a container INSIDE the body like so: body div/div /body -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of BlueStunt Sent: Friday, January 02, 2009 9:29 AM To: jquery-en@googlegroups.com Subject: [jQuery] How to set the HTML background I want to be able to change the background of the page, I can successfully do $(document.body).css(background, yellow); but I have two separate css backgrounds, one sets the body tag and one sets the html tag. So how do I set the html tags background I've tried $(document.html).css(background, yellow); but it won't work :/ -- View this message in context:http://www.nabble.com/How-to-set-the-HTML-background-tp21252706s27240... 06.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
nice example, now i think i get it. Indeed actionscript (v2 at least) is based on ecmascript, much like javascript if i'm not mistaken. I came to web design/dev from actionscript one and gradually made my way to jquery. Anyway, actionscript keeps you away from the internal cooking by using a metaphor, timeline: basically you work with objects and organise them on a main timeline, _root (or _level0). Each object has its own timeline, can be put inside another object, so you would address it as _root.myStepMother.face.hairyChin; I wrongly assumed javascript would allow me to do it for setInterval(). hehe, how boring would be the world without all these little variations, now wouldn't it :) ? That's pretty much the problem with using metaphors: it's nice to get you fast into a certain task, but you have to actually break it up to be able to master the technology behind. Thank you Mike and Peter for your excellent help ! On Sat, Jan 3, 2009 at 2:44 AM, Michael Geary m...@mg.to wrote: Thanks, Alexandre, it's kind of you to say that. About this code... datascape.myInterval = setInterval(window.datascape.move,400); Let's break it down a little. It's exactly the same as doing: var callback = window.datascape.move; datascape.myInterval = setInterval( callback, 400 ); As you can see from this code, JavaScript doesn't remember that the callback function was a property of the datascape object. When you get a reference to the function, that's all you get, a reference to the function itself, without any information about what object the function may have been a method of. So when setInterval calls the function later, it just calls it as a plain old function, and this is the global/window object. Doesn't ActionScript work the same way? It may have a different global object, but I thought most of the JavaScript semantics were similar except for the ActionScript extensions. I haven't worked with ActionScript so I don't know. -Mike From: Alexandre Plennevaux Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read the whole thread it is interesting ) As for this issue after extensive googling i found out that setTimeout and setInterval scope the called function to the window object, not the object the setinterval is called in. Therefore here is how to do it: var datascape = { 'mouseX': 0, 'myInterval': 0, 'create': function(){ var thisObj = this; //-- store this object instance in a variable $('#datascape').bind('mousemove', function(e) { this.mouseX = e.pageX; }).bind(mouseover, function() { datascape.myInterval =
[jQuery] Re: setInterval(obj.method,200) problem: scoping?
Because I'm an advocate for licensing and was told I probably should mention: the 'rescope' function is a stripped down version of Dojo's dojo.hitch function. Infinitely useful in the real world, but technically if used [in production] should retain attribution. It is available under new BSD and AFL terms, (c) Dojo Foundation. Glad you liked it, and hope you can use it. It really is one of my favorite shorthand helpers there is. The cousin [dojo.partial] is useful as well, but not in this context. Regards, Peter Higgins On Fri, Jan 2, 2009 at 9:12 PM, Alexandre Plennevaux aplennev...@gmail.com wrote: nice example, now i think i get it. Indeed actionscript (v2 at least) is based on ecmascript, much like javascript if i'm not mistaken. I came to web design/dev from actionscript one and gradually made my way to jquery. Anyway, actionscript keeps you away from the internal cooking by using a metaphor, timeline: basically you work with objects and organise them on a main timeline, _root (or _level0). Each object has its own timeline, can be put inside another object, so you would address it as _root.myStepMother.face.hairyChin; I wrongly assumed javascript would allow me to do it for setInterval(). hehe, how boring would be the world without all these little variations, now wouldn't it :) ? That's pretty much the problem with using metaphors: it's nice to get you fast into a certain task, but you have to actually break it up to be able to master the technology behind. Thank you Mike and Peter for your excellent help ! On Sat, Jan 3, 2009 at 2:44 AM, Michael Geary m...@mg.to wrote: Thanks, Alexandre, it's kind of you to say that. About this code... datascape.myInterval = setInterval(window.datascape.move,400); Let's break it down a little. It's exactly the same as doing: var callback = window.datascape.move; datascape.myInterval = setInterval( callback, 400 ); As you can see from this code, JavaScript doesn't remember that the callback function was a property of the datascape object. When you get a reference to the function, that's all you get, a reference to the function itself, without any information about what object the function may have been a method of. So when setInterval calls the function later, it just calls it as a plain old function, and this is the global/window object. Doesn't ActionScript work the same way? It may have a different global object, but I thought most of the JavaScript semantics were similar except for the ActionScript extensions. I haven't worked with ActionScript so I don't know. -Mike From: Alexandre Plennevaux Michael, did you know that i 'm becoming a big fan of your explanations? if i follow your explanation correctly, this should have worked, isn't it ? datascape.myInterval = setInterval(window.datascape.move,400); Yet it didn't. I guess i 'm kind of assimilating the javascript window object to actionscript's _root object, and that assumption is probably plain wrong :) On Fri, Jan 2, 2009 at 11:49 PM, Michael Geary m...@mg.to wrote: Hi Alexandre, Don't go adopting a coding practice just because of a single mailing list message. :-) There's nothing wrong with quoting property names in an object literal, but the majority of experienced JavaScript programmers do not quote them except when necessary. As an example, browse through the jQuery source code: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Most of the property names in the code are not quoted, except for those few that are invalid identifiers or reserved words. Regarding setTimeout and setInterval, a minor nitpick on terminology: setTimeout and setInterval scope the called function to the window object. Actually, the *scope* of the called function is determined by its position in the source code. JavaScript uses lexical scoping, where a nested function can directly refer to variables declared in outer functions or in the global scope. That's why your setInterval callback is able to use your thisObj variable, because the interpreter follows the scope chain from the inner function up to the outer function and finds the variable there. What you're talking about is the value of this in the setInterval callback. setInterval and setTimeout call your callback function as a method of the global object (which is the window object in a browser). Or another way to put it is that they don't call the function as a method of any object at all, and by default this is set to the global object. In any case, terminology nitpicks aside, your code is the right way to solve the problem! :-) -Mike From: Alexandre Plennevaux hi donb, according to a lengthy discussion we had on this mailinglist yesterday the quotes are good practice. see: http://groups.google.com/group/jquery-en/msg/821f4eb134c51d3d (is is just one message on a 31-long thread, if u have time ,read
[jQuery] custom function call from document.ready
I have a table which needs to be sorted. Tablesorter plugin does not fully work. I am trying to call a simple alternate function from jQuery $(document).ready method. How to make it work? $(document).ready(function() { $(#tableID).tablesorter({ }); alternate('tableID'); });
[jQuery] Re: change()
Actually ive been using firebug for a while as a CSS developer tool, and i was trying to debug the script, im just not a js guru.. Thank you for your help ;-) On Jan 2, 4:55 pm, Ricardo Tomasi ricardob...@gmail.com wrote: The else statement doesn't accept a condition. Change 'else' to 'else if' and it should be fine, and start using Firebug for Firefox so you can debug your scripts, or Visual Web Developer for IE. On Jan 2, 2:04 pm, Bob O sngndn...@gmail.com wrote: I must not be getting it, this is whati have now, and it is still not working as needed. $(document).ready(function() { var $select = $('select#campaign_type_select'); var $value = $select.val(); var $coupon_div = $('#campaign_create_coupon'); var $broadcast_div = $('#campaign_create_broadcast'); var $contest_div = $('#campaign_create_contest'); $select.bind( 'change keydown', function() { if ($(this).val() == 'contest') { alert('contest'); $coupon_div.show(); $broadcast_div.hide(); $contest_div.hide(); } else if ($(this).val() == 'broadcast') { alert('broadcast'); $coupon_div.hide(); $broadcast_div.show(); $contest_div.hide(); } else ($(this).val() == 'coupon') { alert('coupon'); $coupon_div.hide(); $broadcast_div.hide(); $contest_div.show(); } }); }); HTML - div class=form_data_wrap div class=form_data_labelCampaign Type:/div div class=form_data_value select id=campaign_type_select option value=couponCoupon/option option value=broadcastBroadcast/option option value=contestContest/option /select /div /div On Jan 2, 2:48 am, Michael Geary m...@mg.to wrote: In an event callback function such as the one that's called from .change(), 'this' is not a jQuery object. It is a simple DOM element. You need to wrap it in $() to get a jQuery object if you want to use jQuery methods. Or, you can use DOM properties directly. I would also suggest using a $ prefix on a variable that represents a jQuery object. It's a good visual reminder that you can use jQuery methods on that variable. Also, when using an ID selector, it generally isn't necessary to include the tagname, and in fact the code will be faster if you omit it. For example: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $(this).val() ); }); }); Of course, in this particular case, since you already have the select element wrapped in a jQuery object, $select and $(this) (inside the change function) are the same thing, so you could also do: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.change( function() { alert( $select.val() ); }); }); BTW, I highly recommend triggering on both the change event and the keydown event. This gives better usability when someone uses the keyboard: $(document).ready( function() { var $select = $('#campaign_type_select'); alert( $select.val() ); $select.bind( 'change keydown', function() { alert( $(this).val() ); }); }); The only thing to watch out for there is that you want to know if the value has actually changed on the keydown or not. This would take care of that: $(document).ready( function() { var $select = $('#campaign_type_select'); var value = $select.val(); alert( value ); $select.bind( 'change keydown', function() { var newvalue = $(this).val(); if( newvalue != value ) { value = newvalue; alert( value ); } }); }); -Mike From: Bob O Hello all, a little new the js and jquery any help would be fantastic... I have this in my linked myFx.js file: $(document).ready(function() { var selected_type = $('select#campaign_type_select'); var coupon_div = $('#campaign_create_coupon'); var broadcast_div = $('#campaign_create_broadcast'); var contest_div = $('#campaign_create_contest'); // alert(selected_type.val()); I CAN GET THIS TO FIRE WHEN UNCOMMENTED, and it returns the the value coupon as i would expect. BUT THIS ISNT WORKING ive tried various renditions (this.val(), selected_type, etc...) based on what i have read on this site and the jQuery site with 0 success. selected_type.change(function() { if (this.val() == 'contest') { alert('contest'); } else if (this.val() == 'broadcast') {
[jQuery] Adding an onClick funtion to existing working menu - need 2 or 3 things to unload/load
Hi All... Really sorry to be going over this again. It's been one solid week all day and night. I know more, though not enough yet. Hope this is easy to understand. I REALLY need help. I've tried 100's of things all thru new years eve and day as well. hehehe WORKING menu must stay working though I seem to be able to add anything to each li and it still works. SO what code should I add to get a bunch of hidden divs to TOTALLY load and unload IN the same spot? I won't post a bunch of JQuery script code. I've tried about 100 things or so... And studied for days. There's 3 menu sections. Here's the first one: - li a href=#first class=firstITEM Menu section A/a ul class=first lia href=#first-a ADD unique class, name, rel??MENU Section A first-a/a/li lia href=#first-bMENU Section A first-b/a/li lia href=#first-cITEM first-c/aMENU Section A first-c/li lia href=#first-dITEM first-d/aMENU Section A first-d/li lia href=#first-eITEM first-e/aMENU Section A first-e/li /ul -- They are the only things I want to be clickable. So when a click occurs on any one of them i need a div (i think?) that is currently hidden to load into another area on the page. I only use one html page and one css file for the whole thing. SO: Then when another menu item (as above) is clicked I need the older div to TOTALLY unload and the new one to load in the same location replacing the old one of course. You see, the divs contain working videos so they need to completely unload then load I believe. At this point the empty divs look like this, (below is code) and when they are unhidden they all show up and will play. Would it be better to put them in something other than li rel= ?? (see below please) The video playing script works well. Though it seems to only work with inline (html code) by using rel= It's probably my unskilled-ness as there's likely other html that would stilll have them work. This is the html that works with the working video play code. The videos do play without the div stuff. I can't figure out what would be better than what's above in the menu. Is li rel= a good choice? -- div class=video id=vid1 li rel=mediaplayer.swf:vid1.flv name=vid1/rel /div div class=video id=vid2 li rel=mediaplayer.swf:vid2.flv name=vid2/rel /div div class=video id=vid3 li rel=mediaplayer.swf:vid3.flv name=vid3/rel /div div class=video id=vid4 li rel=mediaplayer.swf:vid4.flv name=vid4/rel /div --- I'm really relentless on this though very in the mud stuck. So: I really need to deduce: 1) What's best to add to the menu (class? name? id? rel? ) ... so that I can still have it work as it does and yet add the ability to load and unload completely the divs which will need to be hidden I guess? It would actually be cool to be able to add a slideshow later, so being able to add more triggers later to the menu above would be great. 2) What would be some cool JQuery I could use that would get whatever I add to the menu ('see 1' right above this) that could load and unload the divs individually. ONE unique div (video) for each menu item. 3) I'd love to add a slideshow for each menu item in the future so being able to load and unload a third seperate set of divs into a third location would be great. Well, I can dream...!!! HUGE request here. thank you very much for thinking about my post.
[jQuery] $ is not defined error
I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Will this code validate a number?
I'm running this code to validate that an entry into any field with a class of number is a number after all $,. are disregarded. I'm not getting any response on my page on blur for the field. Is there something wrong with this code? Thanks, Rick $(':input.number').each(function() { $(this).blur(function() { if ( isNaN (this.value.replace ( /[\$\,\./,]))) { $('#' + this.id + '_number_error').fadeIn(500); $('#submit').attr('disabled', 'disabled'); } else { $('#' + this.id + '_number_error').fadeOut(500); $('#submit').removeAttr('disabled'); };
[jQuery] Cannot get dynamically generated link to fire
The code is below. I cannot get the link that was added to the liblue/li to be fired after the code is ran. It works fine for Item1 remove me link Any ideas? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title script language=javascript type=text/javascript src=jquery-1.2.6.min.js/script script type=text/javascript $(document).ready(function(){ $(.color).click(function(){ //alert(You are now leaving the site.); //$(this).hide(); //alert($(this).attr(title)); $(#list1).append(li+$(this).attr(title)+a href='#' class='removeme'Remove/a/li); return false; }); $(.removeme).click(function() { alert(Remove); return false; }); }); /script /head body ul id=list1 liItem 1 a href='' class='removeme'Remove/a/li liItem 2/li liItem 3/li /ul a href= id=blue title=blue class=colorAdd/a /body /html
[jQuery] Re: Cannot get dynamically generated link to fire
Just a possibility, Randy, but this might be one of those cases where you could use the LiveQuery plug-in to re-bind the link after the DOM has been updated with your new HTML. Check this out and see if it helps you. http://brandonaaron.net/docs/livequery/ Rick -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Randy Johnson Sent: Friday, January 02, 2009 11:43 PM To: jQuery (English) Subject: [jQuery] Cannot get dynamically generated link to fire The code is below. I cannot get the link that was added to the liblue/li to be fired after the code is ran. It works fine for Item1 remove me link Any ideas? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title script language=javascript type=text/javascript src=jquery-1.2.6.min.js/script script type=text/javascript $(document).ready(function(){ $(.color).click(function(){ //alert(You are now leaving the site.); //$(this).hide(); //alert($(this).attr(title)); $(#list1).append(li+$(this).attr(title)+a href='#' class='removeme'Remove/a/li); return false; }); $(.removeme).click(function() { alert(Remove); return false; }); }); /script /head body ul id=list1 liItem 1 a href='' class='removeme'Remove/a/li liItem 2/li liItem 3/li /ul a href= id=blue title=blue class=colorAdd/a /body /html
[jQuery] Re: Will this code validate a number?
Nevermind... I figured out what was wrong. I needed another / after the bracket to terminate the regex. -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Rick Faircloth Sent: Friday, January 02, 2009 10:28 PM To: jquery-en@googlegroups.com Subject: [jQuery] Will this code validate a number? I'm running this code to validate that an entry into any field with a class of number is a number after all $,. are disregarded. I'm not getting any response on my page on blur for the field. Is there something wrong with this code? Thanks, Rick $(':input.number').each(function() { $(this).blur(function() { if ( isNaN (this.value.replace ( /[\$\,\./,]))) { $('#' + this.id + '_number_error').fadeIn(500); $('#submit').attr('disabled', 'disabled'); } else { $('#' + this.id + '_number_error').fadeOut(500); $('#submit').removeAttr('disabled'); };
[jQuery] Re: $ is not defined error
Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Re: Cannot get dynamically generated link to fire
Rick, That did the trick. Thank You! Randy On Jan 3, 12:18 am, Rick Faircloth r...@whitestonemedia.com wrote: Just a possibility, Randy, but this might be one of those cases where you could use the LiveQuery plug-in to re-bind the link after the DOM has been updated with your new HTML. Check this out and see if it helps you. http://brandonaaron.net/docs/livequery/ Rick -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Randy Johnson Sent: Friday, January 02, 2009 11:43 PM To: jQuery (English) Subject: [jQuery] Cannot get dynamically generated link to fire The code is below. I cannot get the link that was added to the liblue/li to be fired after the code is ran. It works fine for Item1 remove me link Any ideas? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title script language=javascript type=text/javascript src=jquery-1.2.6.min.js/script script type=text/javascript $(document).ready(function(){ $(.color).click(function(){ //alert(You are now leaving the site.); //$(this).hide(); //alert($(this).attr(title)); $(#list1).append(li+$(this).attr(title)+a href='#' class='removeme'Remove/a/li); return false; }); $(.removeme).click(function() { alert(Remove); return false; }); }); /script /head body ul id=list1 liItem 1 a href='' class='removeme'Remove/a/li liItem 2/li liItem 3/li /ul a href= id=blue title=blue class=colorAdd/a /body /html
[jQuery] How to call ClueTip direct and pass the Tip as a parameter
Hello, Is it possible to use ClueTip in such a manner as to simply call the ClueTip and pass it the title and tip as a parameter? I posted a question a few days ago about how to get ClueTip to open from a link in an Iframe document so that it opens in the parent window (instead of being clipped at the edge of the IFrame. I have ran across another DHTML tooltip that I can call in this fashion and it DOES work as it needs to, but it is not as nice as ClueTip. It uses an OnMouseOver Javascript event to call a function that passes the tip from the link up to the parent window. If I can find out how to call ClueTip in this manner, then I may be able to do the same thing with it. Thanks! Chuck
[jQuery] Re: $ is not defined error
Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!