[jQuery] Re: jquery json

2009-05-31 Thread Chuck Harmston

jQuery actually has built-in methods for loading and parsing JSON.

Check out the $.getJSON method, which is actually a wrapper for the
$.ajax function with most parameters already handled for you.

http://docs.jquery.com/Ajax/jQuery.getJSON
http://docs.jquery.com/Ajax/jQuery.ajax

Chuck Harmston
http://chuckharmston.com




On Sun, May 31, 2009 at 2:20 PM, Chuck Harmston ch...@chuckharmston.com wrote:
 jQuery actually has built-in methods for loading and parsing JSON.

 Check out the $.getJSON method, which is actually a wrapper for the
 $.ajax function with most parameters already handled for you.

 http://docs.jquery.com/Ajax/jQuery.getJSON
 http://docs.jquery.com/Ajax/jQuery.ajax

 Chuck Harmston
 http://chuckharmston.com


 On Sun, May 31, 2009 at 1:36 PM, Peter Marino marino.pe...@gmail.com wrote:
 Hi jQuery,
 I've just found out the existence of json... and apparently there should be
 a jquery json script somewhere..
 where? think it's called jquery.json.js I would like to download it from the
 site that created it.
 regards,
 Peter
 --
 Power Tumbling - http://www.powertumbling.dk
 OSG-Help - http://osghelp.com




[jQuery] Re: show element if class matches current bod y id (Please help) « View previous topic :: View next topi c » Author

2009-04-19 Thread Chuck Harmston
Hi Matt,
Give this a shot:

$(document).ready( function(){
 $( '#menu ul' ).hide();
 $( '#menu li.' + $( 'body' ).attr( 'id' ) + ' ul' ).show();
});

Demo here: http://jsbin.com/ehape

Chuck Harmston
http://chuckharmston.com

On Sat, Apr 18, 2009 at 10:50 AM, Max mackerma...@gmail.com wrote:


 hi Im new to jquery and having some trouble adapting the code below.
 the function is for a accordion menu. I want it to recognize the
 body's id, and show the sub menu who's class matches the body id.
 right now it is set to show the submenu with class=test.

 function initMenu() {

 $('#menu ul').hide();
 $('#menu ul.test').show();
 $('#menu li a').click(
 function() {
 $(this).next().toggle();
 }
 );
 }
 $(document).ready(function() {initMenu();});


 do i start with something allong the lines of
 var bodyid = $(body).attr(id);
 ?

 Any suggestions greatly appreciated.

 Thanks
 -Max



[jQuery] Re: simple query does not work

2009-04-12 Thread Chuck Harmston
I'm not quite sure what you're trying to do here. The $.get() function is
used to submit an HTTP GET request. See:

http://docs.jquery.com/Ajax/jQuery.get

Are you trying to return the first response? Try using $(div#photolinks
img:first).

Chuck Harmston
http://chuckharmston.com


On Sun, Apr 12, 2009 at 5:41 PM, dongle tetri...@gmail.com wrote:


 i am making this(it does not work) :

 $(document).ready(function(){


  $(div#photolinks img).get(0).css(border,5px solid black;);


 });

 if i do this:

 $(document).ready(function(){


  $(div#photolinks img).css(border,5px solid black;);


 });


 it does work, whats wrong?
 thanks


[jQuery] Re: Function Problem

2009-04-12 Thread Chuck Harmston
I would imagine that this fixes your problem:

$(document).ready(function(){
 $(#showwhat).change( function(){
  onSelectChange(#showwhat));
 });
 });

But I'm not sure that this is the best way to approach this particular
problem. Try the code found here:

http://jsbin.com/udamo

Chuck Harmston
http://chuckharmston.com


On Sun, Apr 12, 2009 at 12:49 PM, djn12313 djn12...@gmail.com wrote:


 New to jQuery and trying to port a simple Select-Box-Value-Hides/Shows-
 a-Text-Box script from JS to jQuery. I'm sure this must be something
 simple, but it's driving me nuts.

 Note:  The following function is just an example for testing.  If I
 define  call the Function below without any parms (e.g. explicitly
 set the #showwhat option:selected inside the function), it works
 fine.  But I have 2 Select Boxes where I need this behavior and would
 like (if only for the sake of principle) to be able to pass in the
 Selector and Value.

 When passing in the Selector as a variable, the following snippet
 executes only when the document loads, but not when the Selection
 changes.  As mentioned if I explicitly set the #showwhat
 option:selected inside the function the script executes the alert
 each time the Select Box value changes.

 Can anyone identify why this isn't working with the variable?  Maybe a
 syntax problem forming the string with the variable?

 ---  sample 

 $(document).ready(function(){
$(#showwhat).change(onSelectChange(#showwhat));
  });

 function onSelectChange(test){
var selected = $(test +  option:selected);
var output = ;
alert(selected.text());
if(selected.text() == Tomorrow){
output = You Selected  + selected.text();
}
$(#output).html(output);
 };



[jQuery] Re: How to remove error messages from Validation Plugin

2009-04-11 Thread Chuck Harmston
I don't recommend this, as it will stop users from submitting the form
without giving them a reason for it. Talk about a usability nightmare.
However, if you insist on it, there is a simple enough solution: just use
CSS to style the .error class:

label.error{display:none}

Chuck Harmston
http://chuckharmston.com


On Fri, Apr 10, 2009 at 10:08 PM, Rick r...@marketingease.com wrote:


 I'm using this plugin in its simplest form..
 http://docs.jquery.com/Plugins/Validation

 All I have is this for my code:

 script
 $(document).ready(function(){
$(#form).validate();
 });
 /script

 It works fine, but I'm trying to hide the error messages which it
 defaults to This field is required. The error message shows up in a
 label..

 How in the world do I hide those error messages within those labels???
 I'm sure it's easy, but I cannot find any examples anywhere!!

 Thanks to whoever helps out..



[jQuery] Re: jQuery Cycle -- Thumbnail Paging

2009-04-11 Thread Chuck Harmston
Hi Amy,

Do the thumbnails follow any naming convention? It wouldn't be terribly
difficult to use a callback to replace the standard Cycle pager with
thumbnails if we are easily able to determine the thumbnail URLs.

Chuck Harmston
http://chuckharmston.com

On Fri, Apr 10, 2009 at 7:24 AM, amuhlou amysch...@gmail.com wrote:


 Hi everyone,

 I'm working on an implementation of the Cycle plugin and would like to
 use thumbnails for the paging.  The tricky part is that my images are
 pulled from a php file, so I'm unsure of how to get the thumbnail
 images to load since the source images aren't loaded into the DOM all
 at once.

 My example is located at:
 http://static.spartaninternet.com/sandbox/carousel2/

 The php file looks like the following:
 img src=images/large/beach.jpg alt=beach /
 img src=images/large/beach2.jpg alt=another beach /
 img src=images/large/beachsunset.jpg alt=beach at sunset /
 img src=images/large/frogs.jpg alt=beach /
 img src=images/large/market.jpg alt=market /
 img src=images/large/monkey.jpg alt=a little monkey /
 img src=images/large/monkey2.jpg alt=a second monkey /
 img src=images/large/rooftops.jpg alt=rooftops /
 img src=images/large/volcano.jpg alt=volcano /
 img src=images/large/waterfall.jpg alt=waterfall /

 Any help would be greatly appreciated!
 ~Amy


[jQuery] Re: JSON , PHP, MySQL, and jQuery

2009-04-09 Thread Chuck Harmston

Alternatively, you can use jQuery's $.getJSON() function, which
automatically parses the JSON data and returns if as a Javascript
object.

Chuck Harmston
http://chuckharmston.com

On Thursday, April 9, 2009, donb falconwatc...@comcast.net wrote:

         $.get(includes/functions_inside.php, {function :
 getAppList},
                 function(data, textStatus){
                         alert( data[0] );
                 },
               'json'
         );

 Specify the return data type as 'json'.

 On Apr 8, 10:21 pm, Renato Untalan phis...@gmail.com wrote:
 I'm having trouble parsing JSON in Javascript.

 The response i'm getting from PHP when making a request is:
 [
 {'name': 'John', 'lastName': 'Doe','age':'25', 'height': '170',
 'weight': '120'},
 {'name': 'Jane', 'lastName': 'Doe','age':'26', 'height': '175',
 'weight': '121'},
 {'name': 'Jack', 'lastName': 'Doe','age':'27', 'height': '180',
 'weight': '122'} ]

 How would I go about parsing this in Javascript?  Am I not encoding it
 correctly on the PHP Side?

 Here's my JAVASCRIPT:
         $.get(includes/functions_inside.php, {function : getAppList},
                 function(data, textStatus){
                         alert( data[0] );
                 }
         );

 Here's my PHP:

         $AppListQuery = $insideDB-customQuery($query);
         $rows = array();
         while($r = mysql_fetch_assoc($AppListQuery)) {
             $rows[] = $r;
         }
         print json_encode($rows);

 Thanks in advance!

-- 
Chuck Harmston
cpharms...@gmail.com
Cell: (612) 961-0690


[jQuery] Re: How to select :inp...@type=text] OR :inp...@type=password]

2009-04-09 Thread Chuck Harmston

$('input[type=text],input[type=password]')

Chuck Harmston
http://chuckharmston.com

On Thursday, April 9, 2009, Nick Boutelier nboutel...@gmail.com wrote:

 How do you use an OR statement in a selector function? For example...

 $(':inp...@type=text,password]').each(function(){
    // do something to a text or password input
 });


-- 
Chuck Harmston
cpharms...@gmail.com
Cell: (612) 961-0690


[jQuery] Re: Debugging jQuery in Firebug

2009-04-07 Thread Chuck Harmston
There are a few cool methods for debugging Javascript in Firebug:

   - In addition to everybody's favorite console.log() method, there is also
   console.debug(), console.info(), and console.error(), each of which are
   color coded differently. If you use console.error(), then it actually logs
   it as a Javascript error, even if the syntax is correct.
   - console.trace() will give you a detailed stack trace, providing the
   funtions on the stack and the values of each argument.
   - console.dir(object) will dump all the properties of the passed object
   - console.dirxml(element) will elegantly dump any XML element. It doesn't
   exist uet, but I'd love a console.dirjson(element) method.
   - You can chunk any logging messages by running console.group(Group
   title) before and console.groupEnd() after a related group of code. You can
   nest as many levels as you'd like.
   -
   - You can track Javascript performance by running console.profile()
   before the code you want to track, then console.profileEnd() afterward.
   Firebug will give detailed information on each method called between the

Chuck Harmston
http://chuckharmston.com


On Tue, Apr 7, 2009 at 1:10 AM, rachel navarro rachelannenava...@gmail.com
wrote:
 i have a related question. how do i track my code? how do i know which
 function is being called first and so on? like having a stack trace. is
 there such a tool for firefox?

 On Tue, Apr 7, 2009 at 6:57 AM, MorningZ morni...@gmail.com wrote:

 how to debug  is a pretty super vague statement

 what are you looking to do?  find objects?  track your code?  watch
 AJAX requests?


 On Apr 6, 10:50 am, jQueryAddict jqueryadd...@gmail.com wrote:
  I've seen a crapload of old posts but none really work well.  Is
  everyone still just using the consol log thingy in Firebug or what?
  I've never used that with jQuery so I do not understand how to debug
  jQuery in Firebug still



[jQuery] Re: [validate] Make at least one input field required

2009-04-07 Thread Chuck Harmston
It'd actually be easier to not use the validation plugin, like so:
http://jsbin.com/afeye

However, remember that you should always use a server-side form validation
backup as well. Any user without Javascript turned on (or screen reader
users, etc) can easily bypass this method.

Hope this helps!

Chuck Harmston
http://chuckharmston.com


On Tue, Apr 7, 2009 at 4:02 AM, Cpt. Archie jimmy.hunni...@gmail.comwrote:


 html looks like:
 input type=text id=email name=email
 input type=text id=tel name=tel
 input type=text id=gsm name=gsm

 i want people to fill in at least one of these fields

 how can this be done using the jquery (validation plugin)?



[jQuery] Re: Cycle plugin pager over image

2009-04-07 Thread Chuck Harmston
Hi Martijn,
You would actually want to do this using CSS, not Javascript. The easiest
way to accomplish this would be to set the container div (the one you
applied the .cycle() method to) to position: relative, then absolutely
position the pager element. If you post the HTML markup you're using, I can
give you more detailed instructions.

Hope this helps!

Chuck Harmston
http://chuckharmston.com

On Tue, Apr 7, 2009 at 8:57 AM, martijn397 martijn...@gmail.com wrote:


 Hello everyone!

 After using the Cycle plugin for quite some time now i was wondering
 if there is any way to get the auto-generated pager shown over my
 image.

 I can only see the .before and .after tags which put the pager above
 or below the image (content), but am unable to find a way to put the
 pager on top of my image (content).

 Thanks for reading,
 Martijn



[jQuery] Re: Cycle plugin pager over image

2009-04-07 Thread Chuck Harmston
It seems to me that this code should have the pager positioned absolutely
over the top left of the image. Do you have a live example that I could take
a look at?
P.S. It probably makes semantic sense to turn the images into an unordered
list :)

Chuck Harmston
cpharms...@gmail.com
Cell: (612) 961-0690


On Tue, Apr 7, 2009 at 10:28 AM, martijn397 martijn...@gmail.com wrote:


 Thanks alot for your response Chuck!

 i'm using the following:

 CSS:
 #slideshow { position:relative; width: 500px; height: 500px;}

 #nav a { padding: 5px 10px 5px 10px; background: white; text-
 decoration: none; color: black }
 #nav a.activeSlide { background: #fbb040; color: white }
 #nav a:focus { outline: none }
 #nav { position:absolute;top:0px; left:0px; margin-top:5px; text-
 align: left; font-family: verdana, arial; font-size: 12px; width:
 630px; height:20px; }

 jQuery:
 $(function() {

$('#slideshow').cycle({
delay: 2000,
timeout: 4000,
speed: 500,
pause: 1,
pager: '#nav'
});

 });

 HTML:
  div id=slideshow
 img src=http://farm4.static.flickr.com/
 3561/3420671870_e409274ea7.jpg border=0 width=500 height=500 /
 /a
 img src=http://farm4.static.flickr.com/
 3169/2922317216_9483a0ed91.jpg border=0 width=500 height=500 /
 /a
 img src=http://farm3.static.flickr.com/
 2371/2407504400_7be3e047a7.jpg border=0 width=500 height=500 /
 /a
 img src=http://farm4.static.flickr.com/
 3125/2370991056_4500f48a03.jpg border=0 width=500 height=500 /
 /a
  div id=nav/div
  /div


 Thanks for looking !!

 best regards, Martijn

 On Apr 7, 3:27 pm, Chuck Harmston cpharms...@gmail.com wrote:
  Hi Martijn,
  You would actually want to do this using CSS, not Javascript. The easiest
  way to accomplish this would be to set the container div (the one you
  applied the .cycle() method to) to position: relative, then absolutely
  position the pager element. If you post the HTML markup you're using, I
 can
  give you more detailed instructions.
 
  Hope this helps!
 
  Chuck Harmstonhttp://chuckharmston.com
 
  On Tue, Apr 7, 2009 at 8:57 AM, martijn397 martijn...@gmail.com wrote:
 
   Hello everyone!
 
   After using the Cycle plugin for quite some time now i was wondering
   if there is any way to get the auto-generated pager shown over my
   image.
 
   I can only see the .before and .after tags which put the pager above
   or below the image (content), but am unable to find a way to put the
   pager on top of my image (content).
 
   Thanks for reading,
   Martijn



[jQuery] Re: How do I access global variables for id's, etc.?

2009-04-07 Thread Chuck Harmston
You certainly can't do it like this. However, using jQuery (it is a jQuery
list, after all ;) ), it's fairly simple:
p id=noJavascriptPlaceholderxyz/p

Then in the Javascript (forget your document.ready):

$( '#noJavascriptPlaceholder' ).attr( 'id', myGlobalVariable );

Of course, if you are well-versed in jQuery selector system, then there is
likely a cleaner way to do it than using a placeholder ID. Hope this is
useful!

Chuck Harmston
http://chuckharmston.com


On Tue, Apr 7, 2009 at 11:53 AM, Rick Faircloth r...@whitestonemedia.comwrote:

  I would like to be able to do something as simple as

 p id=”scriptmyGlobalVariable/script”xyz/p,

 but apparently the “” marks are a problem.



 I’m able to output a global variable value like this:

 pThe value of myGlobalVariable is scriptmyGlobalVariable/script./p



 Is there some way to use global variable values with an id attribute?



 Thanks,



 Rick



 *
 ---
 *

 *It has been my experience that most bad government is the result of too
 much government. - Thomas Jefferson*



[jQuery] Re: first child

2009-04-07 Thread Chuck Harmston
This will return the tag name of a container's first child:

$('#container  *')[0].tagName;

Hope it's useful!

Chuck Harmston
http://chuckharmston.com

On Tue, Apr 7, 2009 at 11:37 AM, bart b...@ivwd.nl wrote:


 Hello all,

 Let's say I'd have a div#content and I'd like to figure out what the
 first child of this div is. It could be an anchor, a paragraph, a
 heading who knows... I know the :first-child selector but this doesn't
 do what I want to accomplish as it just filters within the matched
 selector for the first child.

 Ultimately I'd like to figure out what element this first-child is. I
 can do this with .is() right?

 var $el = xx.is('h2'); //if it indeed matches a h2, returns true?

 Anyone willing to help out?


[jQuery] Re: How do I access global variables for id's, etc.?

2009-04-07 Thread Chuck Harmston
Heh, duh.
p id=”scriptdocument.write(myGlobalVariable)/script”xyz/p

That's not best practice, though. You should use DOM scripting to ensure
unobtrusive Javascript (see
http://www.alistapart.com/articles/behavioralseparation).

Chuck Harmston
http://chuckharmston.com

On Tue, Apr 7, 2009 at 12:09 PM, brian bally.z...@gmail.com wrote:


 I don't think it's the quotes that are the problem. Those are, after
 all, perfectly legitimate characters within a tag. Now, script tags,
 OTOH ...

 Why don't you just use something server-side?

 On Tue, Apr 7, 2009 at 11:53 AM, Rick Faircloth
 r...@whitestonemedia.com wrote:
  I would like to be able to do something as simple as
 
  p id=”scriptmyGlobalVariable/script”xyz/p,
 
  but apparently the “” marks are a problem.
 
 
 
  I’m able to output a global variable value like this:
 
  pThe value of myGlobalVariable is
 scriptmyGlobalVariable/script./p
 
 
 
  Is there some way to use global variable values with an id attribute?
 
 
 
  Thanks,
 
 
 
  Rick
 
 
 
 
 ---
 
  It has been my experience that most bad government is the result of too
  much government. - Thomas Jefferson