[jQuery] Re: aborting a $.getScript() request

2009-03-26 Thread Karl Rudd

Here's my thoughts:

1) It is reliable when dealing with scripts that exist.
2) No idea.

Karl Rudd

On Thu, Mar 26, 2009 at 9:12 PM, Mauricio (Maujor) Samy Silva
css.mau...@gmail.com wrote:

 You're right. A quick look in the bug tracker turns up this ticket:
  http://dev.jquery.com/ticket/1768
 Karl Rudd

 
 Tks Karl,
 So, there are two questions I made to myself and I am unable to answer:
 1-) Does $.getScript()  is a reliable function to use? Is it a useless one?

 2-) What does documentation at:
 http://docs.jquery.com/Ajax/jQuery.getScript#urlcallback means when says:
 * If you load functions via getScript, make sure to call them after a
 delay.* ?

 Any thoughts?
 Maurício.




[jQuery] Re: aborting a $.getScript() request

2009-03-25 Thread Karl Rudd

If the script does not exist then the insertion of the script
element will fail (which is how cross domain getScript() works). So
you can't really test for a time out.

However  you could set a flag in the success/callback function. After
the getScript() call you could use a setTimeout to test for that flag
after a certain time. If the flag isn't set then the load didn't work
or took too long.

Karl Rudd

On Thu, Mar 26, 2009 at 1:49 AM, Maujor css.mau...@gmail.com wrote:


 I have the following AJAX request.

 $(document).ready(function() {
        var iconLoading = $(' mini.gif ');
        var pluginLoaded = $('Plugin ready');

        var requestScript = function() {
                $(iconLoading).insertAfter('#my_button');
                        $.getScript('http://www.domain.com/jquery.corner.js', 
 function() {
                        $(iconLoadind).hide();
                        $(pluginLoaded).insertAfter('#my_button')
                        .css({background: '#ffc', padding:'3px 5px'})
                        .fadeOut(3000);
        // do something using the just loaded plugin
        });
        });
        };
                $('#my_button').bind('click', requestScript);
 })

 Suppose the requested script is unavailable.
 How do I set a time interval in order to abort the request?


 -
 Maurício Samy Silva
 --
 View this message in context: 
 http://www.nabble.com/aborting-a-%24.getScript%28%29-request-tp22703190s27240p22703190.html
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.




[jQuery] Re: aborting a $.getScript() request

2009-03-25 Thread Karl Rudd

You're right. A quick look in the bug tracker turns up this ticket:

  http://dev.jquery.com/ticket/1768

Karl Rudd

On Thu, Mar 26, 2009 at 3:46 PM, Mauricio (Maujor) Samy Silva
css.mau...@gmail.com wrote:

 However  you could set a flag in the success/callback function. After
 the getScript() call you could use a setTimeout to test for that flag
 after a certain time. If the flag isn't set then the load didn't work
 or took too long.
 Karl Rudd

 
 Hi  Karl
 Thanks a lot for your advise.

 The script is working in Firefox and Opera but fails in IE6/IE7 and Safari
 on Windows.

 Test case at: http://jsbin.com/atacu
 Edit at: http://jsbin.com/atacu/edit

 Any thoughts?

 var iconLoading = $('img src=icon.gif /');
 var pluginLoaded = $('spanPlugin loaded/span');
 var requestScript = function() {
 $('#carrega').unbind('click'); // prevent popup the alerbox on 2nd click
 when request fails
 $(iconLoading).insertAfter('#carrega');

 //  Begins Karl suggestion
 var someTime = setTimeout( function() {
  var flagTime = true;
  if(flagTime) {
  $(iconLoading).hide();
  alert(Error message.)
  }
 }, 3 )  // Wait 30s for request success
 //  End Karl suggestion

 $.getScript('http://www.domain.com/scrip.js', function() {
 clearTimeout(someTime); // Karl suggestion
 $(iconLoading).hide();
 $(pluginLoaded).insertAfter('#carrega')
 .css({background: '#ffc', padding:'3px 5px'})
 .fadeOut(3000);
 // do something using the just loaded plugin
 });
 });
 };
  $('#carrega').bind('click', requestScript);
 })
 --

 Thanks
 Maurício.





[jQuery] Re: observe_field

2009-03-24 Thread Karl Rudd

Sure. Bind a change handler to the select. See
http://docs.jquery.com/Attributes/val for more details.

Karl Rudd

On Wed, Mar 25, 2009 at 9:35 AM, macsig sigbac...@gmail.com wrote:

 Hi guys,
 Is there any way to achieve with jQuery the same goal of prototype
 helper observe_field.

 I have a drop down menu and I wish to change some text according to
 the selected value.

 Thanks





[jQuery] Re: Select class=class1 class2 using jQuery

2009-03-18 Thread Karl Rudd

Yes, it's standard CSS selector behaviour, so it's also standard
jQuery behaviour.

Karl Rudd

On Thu, Mar 19, 2009 at 6:32 AM, bill123 bi...@ssec.wisc.edu wrote:

 I need to select an element like this:

    div class=class_1 class_a/div

 and I've found that both of the following work:

    $(.class_a).filter(.class_1).css(background-color, red);

    $(.class_a.class_1).css(background-color, red);

 The first one makes sense and is documented on the website.  But the
 second one isn't documented anywhere as far as I can tell.

 My question is this: is this, i.e.

   $(.class_a.class_1)

 intended, documented behavior or is this some fluke that is likely to
 disappear?  Is there a URL where this behavior is documented?  I would
 like to use the second selector syntax (i.e., $(.class_a.class_1) )
 but don't want to rely on it if it's likely to disappear.

 Thanks!



[jQuery] Re: namespaces XML parsing

2009-03-18 Thread Karl Rudd

Just a quick note: If you use this with 1.3.x then you'll need to drop
the @, it's been removed from 1.3+.

Karl Rudd

On Thu, Mar 19, 2009 at 4:23 AM, Michael Lawson mjlaw...@us.ibm.com wrote:
 We were running into a similar problem with an AJAX application and here is
 what we did to get around namespaces:

 jQuery(entries).find([...@nodename=namespace:elementName]);

 cheers

 Michael Lawson
 Content Tools Developer, Global Solutions, ibm.com
 Phone: 1-828-355-5544
 E-mail: mjlaw...@us.ibm.com

 'Examine my teachings critically, as a gold assayer would test gold. If you
 find they make sense, conform to your experience, and don't harm yourself or
 others, only then should you accept them.'

 Martijn Houtman ---03/18/2009 01:06:07 PM---On Mar 18, 2009, at 5:52 PM,
 David wrote: For example, in FF, if a look for a tag, I have to write
 ns\\:tag ,


 From:
 Martijn Houtman martijn.hout...@gmail.com
 To:
 jquery-en@googlegroups.com
 Date:
 03/18/2009 01:06 PM
 Subject:
 [jQuery] Re: namespaces XML parsing
 



 On Mar 18, 2009, at 5:52 PM, David wrote:

 For example, in FF, if a look for a tag, I have to write ns\\:tag ,
 but if a look for an attribute I have to write ns:attribute. In
 google Chrome (WebKit), I have to write tag or attribute and it
 works.

 Has this problem been solved, or is there any plugin to deal with it?
 It is veri tedious to code a parsing case for each browser (IE, FF,
 Webkit, etc..)

 AFAIK, this problem has not been solved yet, jQuery does not handle
 namespaces at all. The ns\\:field is more of a hack and does not work in IE
 when parsing to XML (through the AJAX option dataType: xml).

 What you might want to try is removing the dataType option (so that it is
 passed as a string), then replace the : character with something else (e.g.
 a dash). This way the XML parser will leave the namespaces alone.

 Please note that I have not tried this, it's based on the things I have read
 about it.

 Regards,
 --
 Martijn.





[jQuery] Re: is that possible to go back on window unload event

2009-03-13 Thread Karl Rudd

You want the onbeforeunload event.

  http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm

It's non-standard in that you can't actually use it like a normal
event. You'll need to use the old window.onbeforeunload = function()
{ ... } format, not the jQuery.bind(...) format.

Your event handler function actually has to return a string. The
browser will provide a popup which will ask the user whether they want
to leave the page, and include the text you return from your function.

It's an ugly hack but it's the only way you can do anything about a
user closing the window.

Karl Rudd

On Fri, Mar 13, 2009 at 5:28 PM, jack datac...@gmail.com wrote:

 Hi, all
 In $(window).unload(function(){ ... }, is that possible to cancel
 unload event. I mean I would prompt for users if they want to close
 the window. If they don't want, how do I cancel the event?

 Jack


[jQuery] Re: is that possible to go back on window unload event

2009-03-13 Thread Karl Rudd

If they leave the unload event will fire.

Karl Rudd

On 13/03/2009, jack datac...@gmail.com wrote:

 Thanks Karl, how do I know wether users want to leave or don't want to
 leave after all?

 jack


[jQuery] Re: How to synchronize ajax events

2009-03-12 Thread Karl Rudd

I suggest looking at one of the Ajax helper plugins, such as:

  http://plugins.jquery.com/project/AjaxManager

If you want to DIY you'll need to either build some sort of queue or
nest the validation

You could also try the validation plugin (
http://plugins.jquery.com/project/validate ) which has a remote
option.

Karl Rudd

On Fri, Mar 13, 2009 at 10:25 AM, Andy789 e...@abcstudio.com.au wrote:

 Hi All,

 Here is a simple fragment:

  function zipSearch(){
        var zip = $j('input#zip_entry').attr('value');
        validateZip(zip);
        alert('second '+validation);
 ...
 
 }

 function validateZip(zip){
                 $j.post(markers.php, { validate: zip},
        function(xml){
                validation = $j.xml2json(xml, false);
                alert('first '+validation);
        });
 }

 The problem is that the first function (zipSearch) calls validateZip
 and doesn't wait until it gets callback data from php file. So it
 jumps to the next line. I am getting 1st alert ('second '+validation)
 and next the alert from ajax function.

 How can I fix it to make sure the first function waits until
 validateZip gets its callback?

 thanks!


[jQuery] Re: How to synchronize ajax events

2009-03-12 Thread Karl Rudd

That will work but it has some rather unexpected consequences, the
biggest of which is that the entire browser will lock up (UI and all)
until the response comes back from the server (which could be a few
seconds). That's not a good thing to do to a user.

Karl Rudd

On Fri, Mar 13, 2009 at 10:47 AM, James james.gp@gmail.com wrote:

 Setting your 'async' option to 'false' in your AJAX options should
 solve this issue.
 By default AJAX is asynchronous so your script will not wait for your
 AJAX response before it continues. Setting 'async' to false will have
 the script wait.


 On Mar 12, 1:34 pm, Karl Rudd karl.r...@gmail.com wrote:
 I suggest looking at one of the Ajax helper plugins, such as:

  http://plugins.jquery.com/project/AjaxManager

 If you want to DIY you'll need to either build some sort of queue or
 nest the validation

 You could also try the validation plugin 
 (http://plugins.jquery.com/project/validate) which has a remote
 option.

 Karl Rudd

 On Fri, Mar 13, 2009 at 10:25 AM, Andy789 e...@abcstudio.com.au wrote:

  Hi All,

  Here is a simple fragment:

   function zipSearch(){
         var zip = $j('input#zip_entry').attr('value');
         validateZip(zip);
         alert('second '+validation);
  ...
  
  }

  function validateZip(zip){
                  $j.post(markers.php, { validate: zip},
         function(xml){
                 validation = $j.xml2json(xml, false);
                 alert('first '+validation);
         });
  }

  The problem is that the first function (zipSearch) calls validateZip
  and doesn't wait until it gets callback data from php file. So it
  jumps to the next line. I am getting 1st alert ('second '+validation)
  and next the alert from ajax function.

  How can I fix it to make sure the first function waits until
  validateZip gets its callback?

  thanks!




[jQuery] Re: $(byName) $(byClass) in 1.3.2

2009-03-12 Thread Karl Rudd

Use id=whatever rather than name=whatever. In CSS #whatever
refers to an element with id=whatever.

The name attribute is for form elements, not for general elements.

Karl Rudd

On Fri, Mar 13, 2009 at 10:02 AM, radioAM japasc...@gmail.com wrote:

 hello, i'm new at using jQuery and i'm trying to create dynamic
 content.
 the problem is thant i can't retrieve the
 new content by name.
 here is an example to reproduce what i'm saying.

  (function() {

    fn = function() {
        $('.widgetBar').append('div class=\'acc1\'/div');
        var acc = $('.acc1');

        //var htmlText = 'a class=\'widgetBasSelector basic\'Hola!!/
 adiv class=pp name=\'div1\'/div';
        var htmlText = 'a class=\'widgetBasSelector basic\'Hola!!/
 adiv class=pp name=div1/div';

        acc.append(htmlText);

        alert($('#div1').size()); // Returns 0
        alert($('.pp').size());   // Returns 1
    };

    $(fn);

    return;
 })
 ();


 what i'm doing wrong ?
 thanks.



[jQuery] Re: $(byName) $(byClass) in 1.3.2

2009-03-12 Thread Karl Rudd

Quite right, I should have said:

  In general the name attribute is for form controls, rather than
general HTML elements.

Karl Rudd

On Fri, Mar 13, 2009 at 1:25 PM, RobG rg...@iinet.net.au wrote:



 On Mar 13, 11:10 am, Karl Rudd karl.r...@gmail.com wrote:
 Use id=whatever rather than name=whatever. In CSS #whatever
 refers to an element with id=whatever.

 The name attribute is for form elements, not for general elements.

 The name attribute is valid for many more elements than just form
 elements (I guess you really meant form controls), the full list is:

   button, textarea, applet, select, form, frame, iframe, img, a,
   input, object, map, param and meta

 That's 9 out of 14 (64% or nearly 2/3) that *aren't* form controls or
 form elements.


 --
 Rob


[jQuery] Re: Very simple question...

2009-03-11 Thread Karl Rudd

I suggest reading through:

  http://docs.jquery.com/

In this case the page you want is:

  http://docs.jquery.com/Traversing

Karl Rudd

On Thu, Mar 12, 2009 at 10:04 AM, 7times9 7tim...@googlemail.com wrote:

 ...what does eq as in .eq(2) stand for?

 It helps me to read jQuery in my head if I know what abbreviations
 really mean :-)

 Thanks



[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Karl Rudd

Form elements have defaultValue and defaultSelected attributes.
You might want to explore using those to reset the elements.

http://www.irt.org/script/909.htm

Karl Rudd

On Wed, Mar 11, 2009 at 5:58 AM, mkmanning michaell...@gmail.com wrote:

 Haven't tried it but you could use my getAttributes plugin (http://
 plugins.jquery.com/project/getAttributes) to store the current
 attributes in the data as I suggested, and then retrieve it later.
 That would get you not only the value but all other attributes.

 $(document).ready(function(){
        $(:input).each(function(){
                  $(this).data('orig',$.getAttributes($(this)))
        });

        //to access original attributes of the input later, including value
        console.log( $('some_input').data('orig').value );
        console.log( $('some_input').data('orig').name);

 });

 On Mar 10, 11:43 am, Brad nrmlcrpt...@gmail.com wrote:
 Thanks for the help on the other question. I missed the part about
 reverting the value.

 Actually I don't think that I need to explicitly store the value. If I
 store the value of  $(this) as shown I can later retrieve the value
 for a specific field by e.g., calling ...

 $(origFormData['age']).val()

 ..., but I need to explain my requirement in more detail.

 Restoring the input field's value is only one part of the problem.
 There are a number of other attributes that might need to be restored.
 Depending on how the backend code originally displays the form, a
 field can start out enabled or disabled. It can start out with a
 special class assignment. These attributes can dynamically change as
 the form is used. Therefore resetting a field may involve more than
 restoring the field's original value.

 What I was hoping I could do was store an jQuery object that contained
 all of the information about the field and somehow (magically) use
 that to overwrite the current representation of that same field.

 Am I dreaming?

 Thinking of other ways to solve this problem, is there a way with
 jQuery to get the full html of an input element? The .html() method
 doesn't do it.

 On Mar 10, 12:02 pm, MorningZ morni...@gmail.com wrote:

  You forgot an important part of the line

  origFormData[this.name] = $(this);

  and this is you need to store the value, so

  origFormData[this.name] = $(this).val();

  and on your other topic, the code was also provided to revert the
  value back to the saved value

  On Mar 10, 1:36 pm, Brad nrmlcrpt...@gmail.com wrote:

   I have a need to reset individual form objects to their original
   state. When the document loads I save the element like this:

           var origFormData = {};

           $(document).ready(function(){

                   // Save original form data for each input field
                   $(:input).each(function(){
                           origFormData[this.name] = $(this);
                   });

           });

   For example I have a form with fields named name, age, and dept
   selectable by $(#name), $(#age), and $(#dept) respectably.

   How would I go about later restoring/resetting a specific field. Is
   there a simple way to overwrite the object represented by $(#name)
   with origFormData.name?


[jQuery] Re: Jquery 1.3.2 bug in getting checkbox ..... maybe

2009-03-10 Thread Karl Rudd

Remove the @ symbol. It's use has been deprecated for the past few
releases and has now been removed.

http://docs.jquery.com/Release:jQuery_1.3#Changes

Karl Rudd

On Wed, Mar 11, 2009 at 1:56 PM, Plant More Tree markth...@gmail.com wrote:


 Hi guys,

    I upgraded to 1.3.2 from 1.2.6 and the following stop working:

 $(inp...@type=checkbox]).each(function(i, item) {

 });

 where I have almost spent an hour to diagnose it. Hence, I change to the
 following then it works :


 $(#form1 :checkbox).each(function(i, item) {

 });

 hope this may help someone out there

 regards,
 Mark Thien
 Menggaris | The Technology Buddy
 markt |@| menggaris.com
 --
 View this message in context: 
 http://www.nabble.com/Jquery-1.3.2-bug-in-getting-checkbox-.-maybe-tp22447984s27240p22447984.html
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.




[jQuery] Re: OnMouseDown = create draggable, OnMouseUp = create droppable

2009-03-09 Thread Karl Rudd

Try http://jqueryui.com/

Karl Rudd

On Mon, Mar 9, 2009 at 5:33 PM, delphilynx delphil...@gmail.com wrote:

 No one? Is there such a feature in jQuery for this problem?

 Thanks in advance guys! I have al this days been working on this
 issue, and hope someone is willing to take a short look to this
 problem.

 Thanks


[jQuery] Re: OnMouseDown = create draggable, OnMouseUp = create droppable

2009-03-09 Thread Karl Rudd

Sorry, no idea. Haven't used jQueryUI before.

Karl Rudd

On Mon, Mar 9, 2009 at 5:56 PM, delphilynx delphil...@gmail.com wrote:

 Thanks for the answer Karl Rudd,

 But that is what I already have tried. If you read the start post,
 then you see that I want to create the drag and dropable on runtime.
 If there is something what is not clear, please say it.

 Thanks again if someone is willing to read the start post and then
 point me in the right direction.


[jQuery] Re: Using .ajax to do XMLRPC - I must be doing something very stupid

2009-03-09 Thread Karl Rudd

jQuery consumes JSON fairly well but you'd need a plugin/other
functionality (like from json.org or that RPC plugin) to produce
JSON.

Karl Rudd

On Tue, Mar 10, 2009 at 4:00 AM, Ritesh Nadhani rite...@gmail.com wrote:

 Aha.

 And I though I was doing something wrong. That clears up lot of things.

 PS: Does jQuery has better support for json? I can modify my XML-RPC
 to JSON-RPC.

 On Sun, Mar 8, 2009 at 9:44 PM, Karl Rudd karl.r...@gmail.com wrote:

 jQuery doesn't include XML serialisation in it's core. A quick search
 of the plugins repository came up with two projects that might help
 (there may be more):

 RPC
 http://plugins.jquery.com/project/rpc
 The is rpc(remote procedure call) client implementation based on
 JQuery. It creates an rpc object and adds ability to call them. It
 supports both xml and json rpc...

 XML
 http://plugins.jquery.com/project/xml
 Methods to generate XML/HTML tags programmatically. By default, they
 output XHTML compliant tags.

 Karl Rudd

 On Mon, Mar 9, 2009 at 1:18 PM, riteshn rite...@gmail.com wrote:

 Hi

 So my first time using jQuery.

 http://paste.pocoo.org/show/107037/

 I have a simple django based xml-rpc server which works perfect when I
 test it with my python based XML-rpc client.

 I am always getting error when sending data using jQuery.

 When I set processData: true - the server is getting value as:

 var1=val1var2=val2

 as a  consequence of which my dispatcher in the server side fails with
 XML parsing error.

 If I set processData: false, then POST content is just ''.

 Looks like jquery is not serializing the data to XML. I did lot of
 Googling (maybe I didnt do enough) and nowhere I found a similar
 error. Though it threw up: http://drupalbin.com/1173 which is doing
 the serializing by itself. I am doubtful if this is required.

 Thoughts?





 --
 Ritesh
 http://www.riteshn.com



[jQuery] Re: Using .ajax to do XMLRPC - I must be doing something very stupid

2009-03-09 Thread Karl Rudd

Not sure what's happening. I think data is actually a string, so you
might have to convert it to XML nodes before you can search it. I
could be wrong though.

Karl Rudd

On Tue, Mar 10, 2009 at 10:23 AM, Ritesh Nadhani rite...@gmail.com wrote:

 Thanks.

 I had look into that first link earlier but I had hoped that there
 would be a simpler solution. Anyway, I tried using that code and even
 though I am getting XML like: http://paste.pocoo.org/show/107174/ from
 my XMLRPC server, the jquery selector is never satified and ret.result
 is always undefined.

 On Mon, Mar 9, 2009 at 1:53 PM, Karl Rudd karl.r...@gmail.com wrote:

 jQuery consumes JSON fairly well but you'd need a plugin/other
 functionality (like from json.org or that RPC plugin) to produce
 JSON.

 Karl Rudd

 On Tue, Mar 10, 2009 at 4:00 AM, Ritesh Nadhani rite...@gmail.com wrote:

 Aha.

 And I though I was doing something wrong. That clears up lot of things.

 PS: Does jQuery has better support for json? I can modify my XML-RPC
 to JSON-RPC.

 On Sun, Mar 8, 2009 at 9:44 PM, Karl Rudd karl.r...@gmail.com wrote:

 jQuery doesn't include XML serialisation in it's core. A quick search
 of the plugins repository came up with two projects that might help
 (there may be more):

 RPC
 http://plugins.jquery.com/project/rpc
 The is rpc(remote procedure call) client implementation based on
 JQuery. It creates an rpc object and adds ability to call them. It
 supports both xml and json rpc...

 XML
 http://plugins.jquery.com/project/xml
 Methods to generate XML/HTML tags programmatically. By default, they
 output XHTML compliant tags.

 Karl Rudd

 On Mon, Mar 9, 2009 at 1:18 PM, riteshn rite...@gmail.com wrote:

 Hi

 So my first time using jQuery.

 http://paste.pocoo.org/show/107037/

 I have a simple django based xml-rpc server which works perfect when I
 test it with my python based XML-rpc client.

 I am always getting error when sending data using jQuery.

 When I set processData: true - the server is getting value as:

 var1=val1var2=val2

 as a  consequence of which my dispatcher in the server side fails with
 XML parsing error.

 If I set processData: false, then POST content is just ''.

 Looks like jquery is not serializing the data to XML. I did lot of
 Googling (maybe I didnt do enough) and nowhere I found a similar
 error. Though it threw up: http://drupalbin.com/1173 which is doing
 the serializing by itself. I am doubtful if this is required.

 Thoughts?





 --
 Ritesh
 http://www.riteshn.com





 --
 Ritesh
 http://www.riteshn.com



[jQuery] Re: Using .ajax to do XMLRPC - I must be doing something very stupid

2009-03-08 Thread Karl Rudd

jQuery doesn't include XML serialisation in it's core. A quick search
of the plugins repository came up with two projects that might help
(there may be more):

RPC
http://plugins.jquery.com/project/rpc
The is rpc(remote procedure call) client implementation based on
JQuery. It creates an rpc object and adds ability to call them. It
supports both xml and json rpc...

XML
http://plugins.jquery.com/project/xml
Methods to generate XML/HTML tags programmatically. By default, they
output XHTML compliant tags.

Karl Rudd

On Mon, Mar 9, 2009 at 1:18 PM, riteshn rite...@gmail.com wrote:

 Hi

 So my first time using jQuery.

 http://paste.pocoo.org/show/107037/

 I have a simple django based xml-rpc server which works perfect when I
 test it with my python based XML-rpc client.

 I am always getting error when sending data using jQuery.

 When I set processData: true - the server is getting value as:

 var1=val1var2=val2

 as a  consequence of which my dispatcher in the server side fails with
 XML parsing error.

 If I set processData: false, then POST content is just ''.

 Looks like jquery is not serializing the data to XML. I did lot of
 Googling (maybe I didnt do enough) and nowhere I found a similar
 error. Though it threw up: http://drupalbin.com/1173 which is doing
 the serializing by itself. I am doubtful if this is required.

 Thoughts?



[jQuery] Re: Matching on style attribute bug?

2009-03-05 Thread Karl Rudd

You'll need to use a filter(). Have a look at this previous thread:

http://groups.google.com/group/jquery-en/browse_thread/thread/3b22774b4e7c0434

Karl Rudd

On Fri, Mar 6, 2009 at 8:30 AM, ml1 tsummer...@gmail.com wrote:

 I ran into a jquery bug trying this with class, so maybe this is a bug
 too.

 Given this:

   div style=background-image:url(myimage.png);/div

 Shouldn't I be able to select that with this:

   $( 'div[style*=myimage]' )


[jQuery] Re: Objects Methods as event handlers.

2009-03-04 Thread Karl Rudd

Actually the only thing that gets added to elements (apart from the
usual event handlers) is a jQuery123123234124 type attribute. The data
itself is stored in a separate store, away from the DOM elements. This
is also helps deal with memory leakage problems. So no, no global
namespace pollution. The only things exposed to the JavaScript
global namespace is jQuery and $.

The corruption of 'this', as we've explained, isn't a corruption.
It's what's expected my most JavaScript programmers because that's the
way the old onclick= style handlers work.

*shrug* It's all about how you expect things to work.

Karl Rudd

On Thu, Mar 5, 2009 at 8:25 AM, Michael dmgx.mich...@gmail.com wrote:

 And jQuery docs criticize prototype for polluting the global namespace
 and in the same breath recommend binding element properties that would
 normally go on a class to elements with all the potential namespace
 collisions that brings?

 O... K.. (backs away slowly).

 Honestly, the more I use this framework the less I like it.  The
 corruption of 'this' is a major flaw in the framework I don't think
 I'll ever be happy with.

 On Mar 3, 10:32 pm, Dave Methvin dave.meth...@gmail.com wrote:
  one area of functionality has me befuddled
  - using object methods to handle events.

 To continue Karl's point, if you use jQuery the same way you would use
 prototype then you'll be fighting it all the way. The prototype
 solution squirrels away references to the DOM objects in the class and
 then points event handlers back to the class. jQuery usually
 encapsulates the data and events within the DOM element or a closure,
 e.g.:

 $(selector)
   .data(options, {answer: 42})
   .click(function(){
      alert($(this).data(options).answer)
   });


[jQuery] Re: Attempting to convert to jQuery

2009-03-04 Thread Karl Rudd

This is being discussed in another thread at the moment (
http://groups.google.com/group/jquery-en/browse_thread/thread/b7eadd9ca0a683a4
).

There are a few plugins that you can try that should help:

  http://plugins.jquery.com/project/bind
  http://higginsforpresident.net/js/jq.hitch.js

Karl Rudd

On Wed, Mar 4, 2009 at 10:09 PM, theadam adam.parchimow...@gmail.com wrote:

 Hi,

 I am atempting to cover a simple custom solution from prototype to
 jQuery and I came a long a problem I am unable to solve.

 I have added some behaviours to the app, like sorting divs and
 switching their visibility. I know there are plugins for this but
 while checking them out I couldn't make then do what I wanted (i.e.
 there was no sorting plugin that would allow me to disable dragging
 the elements and enable me to create handlers for moving them up /
 down).
 I managed to create my own plugin that accepts extra handlers on
 reordering elements, but there is another feature I need. I want the
 state of all the reordering and showing/hiding to be stored in cookies
 and I wanted to create a js class to handle a simple json object that
 would be stored in cookies (couldn't think of a jQuery plugin way to
 accomplish this). What I wanted to do was to pass a handler (a certain
 method of this object) as a parameter to jQuery plugin. However there
 is no bind(this) method known from prototype to bind the context to a
 handler, and the handler method requires the access to the object.

 If I wasn't clear on this let me know. To sum this up - I want to
 create custom reordering / visibility toggling behaviour + independent
 class / plugin for storing the state of those operations and loading
 it up on the page load.



[jQuery] Re: Objects Methods as event handlers.

2009-03-03 Thread Karl Rudd

First a solution for you. Try this plugin:

  http://plugins.jquery.com/project/bind

Now a note about the way jQuery is biased (which you can skip if you prefer).

jQuery is primarily focused on DOM elements. Everything else gets
attached to those elements. It's not a bad thing, it's just
different to what many expect. What I mean by this is if you instead
consider DOM elements to be views of internal objects then you'll
find your mindset clashing with the way jQuery is biased.

You've already come across the bias as you can see the bind() function
binds a function to a DOM element, and the this inside the handler
actually refers to the DOM element rather than some external object.

Karl Rudd

On Wed, Mar 4, 2009 at 10:30 AM, Michael dmgx.mich...@gmail.com wrote:

 I've recently taken on a job where I have been required to use jQuery
 instead of my usual framework of choice - prototype. I've handled the
 transition well enough but one area of functionality has me befuddled
 - using object methods to handle events. I've been working around the
 problem but the workarounds are quite ugly.

 An explanation. First I'll give the code as it would look in prototype

 myClass = Class.create({
        this.element: null,
        this.initialize: function( element ) {
                this.element = element;
                element.observe('click', 
 this.onClick.bindAsEventListener(this));
        },

        this.onClick: function(e) {
                // actions on click here.
        }
 });



 Now I know how to build classes in javascript without prototype's
 Class library. I also know how to use late binding and prototype
 modifications to achieve what that library abstracts. The problem is
 how am I supposed to replicate bindAsEventListener? I've tried...

 myClass = function( element ) {
        // element is an element somewhere in the dom that this class will
 manage a behavior for.
        // Assume for the purposes of this example that it's already
 encapsulated in a jQuery object
        this.element = element;

        this.onClick = function() {
                // on click actions.
        }

        this.element.bind('click', this.onClick );
 }

 If I run the code as above the meaning of 'this' is lost.
 Unfortunately

 this.element.bind('click', this.onClick ).apply(this); // more or less
 what .bindAsEventListener actually does.

 won't work - it causes jQuery to issue an error.  So how is anyone
 supposed to use object methods to handle events, a cornerstone of
 object oriented programming?

 If I'm to continue using this framework I need to find a solution to
 this problem.



[jQuery] Re: click event and window.location problem in safari

2009-02-27 Thread Karl Rudd

Try this plugin:

http://newism.com.au/blog/post/58/bigtarget-js-increasing-the-size-of-clickable-targets/

Karl Rudd

On Sat, Feb 28, 2009 at 1:49 AM, introvert aljaz.faj...@gmail.com wrote:

 Hello

 I have a simple jquery code that will put a link (on click event) on a
 division. The link is read from the anchor inside of the div:

 $(document).ready(function() {
   $(div.picture).click(function () {
        var url = $(this).find(a).attr('href');
        window.location = url;
   });
 });

 This code will work fine in Firefox and IE, but in Safari it will
 return user to the url:
 http://someurl.com/http://someurl.com

 instead of:
 http://someurl.com

 How to fix this?
 Any ideas?

 Thanks a lot for help!


[jQuery] Re: tbody:first-child thead

2009-02-25 Thread Karl Rudd

tbody:first-child doesn't select the first child of the tbody it
says select the tbody that is the 'first-child' of it's parent.

So what you are actually wanting to say is:

$(#myTable tbody tr:first-child)

Which is select the tr that is the first child of tbody

http://docs.jquery.com/Selectors/firstChild

Karl Rudd

On Wed, Feb 25, 2009 at 8:08 PM, Alex Wibowo alexwib...@gmail.com wrote:
 sorry i should say
 how does that explain the behaviour when there's no thead (because it
 works when thead doesnt exist)

 On Wed, Feb 25, 2009 at 8:06 PM, Alex Wibowo alexwib...@gmail.com wrote:

 how does that explain the behaviour when there's thead then??


 On Wed, Feb 25, 2009 at 7:47 PM, David Muir davidkm...@gmail.com wrote:

 It's because tbody:first-child is already selecting the tr, so you're
 effectively doing:
 tbody tr tr (where the first tr is the first child of tbody)

 Cheers,
 David


 Alex Wibowo wrote:

 Hi all,

 I have a code that counts the number of rows in a table...

 the table looks like:

 table id=myTable
  thead
   ...
   /thead

   tbody
        tr
         
        /tr
  /tbody
 /table


 and my jquery looks like:

 $(#myTable  tbody:first-child  tr).length;

 strange enough that always returns 0.
 but if i remove the thead from the table... then it will return the
 correct number of rows..

 or alternatively, i can keep the thead, but use the following instead:

 $(#myTable  tbody  tr).length;

 i.e. without specifying first-child.

 Can anyone explain this behaviour?



 THanks a lot!



 --
 Best regards,


 WiB





 --
 Best regards,


 WiB




 --
 Best regards,


 WiB




[jQuery] Re: Is this a valid selector?

2009-02-24 Thread Karl Rudd

The scrollTo function takes

On Wed, Feb 25, 2009 at 1:40 PM, Rick Faircloth
r...@whitestonemedia.com wrote:
 (‘div.section:last’)  ???



 I’m trying to use it in this code:



 $(document).ready(function() {



  $(‘#add-section’).livequery(‘click’, function() {

   $.scrollTo(‘div.section:last’, 1000);

  });



 });



 FF3 does nothing with it…IE7 scrolls close to the top

 of the page, rather than to towards the bottom

 where the ‘last div with class=section’ has been created.



 Ideas on how to make this work, anyone?



 Thanks,



 Rick


[jQuery] Re: Is this a valid selector?

2009-02-24 Thread Karl Rudd

Apologies for the last post, I clicked send before I was ready.

Check to see that the 'div.section:last' selector actually returns a
valid jQuery object. (So check that $('div.section:last').length  0)

Karl Rudd

On Wed, Feb 25, 2009 at 1:40 PM, Rick Faircloth
r...@whitestonemedia.com wrote:
 (‘div.section:last’)  ???



 I’m trying to use it in this code:



 $(document).ready(function() {



  $(‘#add-section’).livequery(‘click’, function() {

   $.scrollTo(‘div.section:last’, 1000);

  });



 });



 FF3 does nothing with it…IE7 scrolls close to the top

 of the page, rather than to towards the bottom

 where the ‘last div with class=section’ has been created.



 Ideas on how to make this work, anyone?



 Thanks,



 Rick


[jQuery] Re: JQuery: Dynamically added fields values are not submitted

2009-02-16 Thread Karl Rudd

First of all if you're using jQuery 1.3.x you need to remove the @
at the start of attribute selectors. ie [...@name='blah'] becomes
[name='blah'].

Second, technically you can't put a form as a direct child of a table.
Instead wrap the table in the form. This is why your stuff isn't
getting submitted (at least in Firefox).

Karl Rudd

On Tue, Feb 17, 2009 at 1:27 PM, Bluesapphire michealg...@gmail.com wrote:

 Hi!
 Kindly visit following link:

 http://vibersol.com/sitesdemo/shipping/admin/addquotation.php

 Then add form fields dynamically [by clicking GREEN icon]. And fill
 these fields. After that submit the form.

 I checked in FireBug that these values of dynamically added fields are
 not submitted by form. So values of these dynamically added fields are
 not submitted to next PHP page.

 What and where Iam doing wrong ?

 Thanks in advance


[jQuery] Re: .load() and timing

2009-02-15 Thread Karl Rudd

You'll probably need to supply a snippet of the relevant bit of your
code. It could be a number of things.

Make sure you're doing the modifications to the loaded HTML (which
will be located in the element you've chosen) in the callback
function.

You might be better off using the $.get() function or the full
ajax() function. They offer a lot more flexibility, such as not
directly dumping the newly loaded HTML into the document. You get a
chance to process it and put it where you want it to go.

Karl Rudd

On Mon, Feb 16, 2009 at 4:05 PM, jhm jmay...@gmail.com wrote:

 I'm new to jquery and so far it's awesome. I've run into a problem,
 however, that I don't fully understand how to deal with. (sorry for
 the cross post, if it is one, I accidentally posted this originally in
 the UI group).

 I'm using .load() to load a snippet of HTML in response to a click. I
 need to modify the HTML, based on what was clicked. Even though I do
 the modifications after the snippet is loaded, the modifications seem
 to operate on the initial HTML instead of the freshly loaded code.

 I figure there is a timing issue I'm missing, but I also figure this
 must be possible.

 Any advice?

 Thanks!



[jQuery] Re: .load() and timing

2009-02-15 Thread Karl Rudd

Ajax is asynchronous, which is to say that you make the call to get
the data, then it could take a few seconds for it to appear. During
that time JavaScript code keeps going. So your code for populate
fields most executes before the page snippet is actually loaded.

What you need to do is:

function addActivity(activity, name, id)
{
// load activity snippet
$(#activity).load('activity.html', function() {
// populate fields in a form
$('#ModName').val(name);
$('#ModID').val(id);
});
}

The callback function (that in this case is the second parameter in
the load function) gets called once snippet has actually returned.

Be aware that if the loading fails the callback function still gets
called. If you want more control you'll need to use the $.ajax()
function. http://docs.jquery.com/Ajax/jQuery.ajax#options

Karl Rudd



On Mon, Feb 16, 2009 at 5:05 PM, jhm jmay...@gmail.com wrote:

 You'll probably need to supply a snippet of the relevant bit of your
 code. It could be a number of things.

 Is this enough?

function addActivity(activity, name, id)
{
// load activity snippet
$(#activity).load('activity.html');

// populate fields in a form
$('#ModName').val(name);
$('#ModID').val(id);
}


 Make sure you're doing the modifications to the loaded HTML (which
 will be located in the element you've chosen) in the callback
 function.

 Maybe this is where I'm going wrong. I'm trying to modify specific ids
 in the document (which I assumed now includes the freshly loaded
 code).

 Thanks!



[jQuery] Re: Problem reading rss link tag

2009-02-14 Thread Karl Rudd

link tags only have attributes, they don't contain anything.

Karl Rudd

On Sat, Feb 14, 2009 at 11:31 AM, Karthik
karthick.vijayara...@gmail.com wrote:

 Hi,
  I am trying to parse a rss feed. My code seems to be able to extract
 the value for any tag in the feed except the link tag. I am using
 Firefox 3.0.6.

 $.get(pressRelease1.xml,{},function(d){
$(d).find('item').each(function() {
var $item = $(this);

var title = $item.find('title').text(); //this works
var description = $item.find('description').text(); //this 
 works too
var link = $item.find('link').text(); //this doesnt work
});
 });

 When i turned on Venkman's javascript debugger, the innerHtml had
 something like this:
  linkBla Bla Bla\n .
 It seems to be missing the the end tag for link. I cant seem to
 understand this behavior. I googled a lot but i couldnt find posts
 related to this problem. I am very sure that there is nothing wrong in
 my feed. If you have come across something like this, can you please
 help? Thank you.

 Thanks
 Karthik



[jQuery] Re: Safari and .remove()

2009-02-14 Thread Karl Rudd

In the past Safari has been a bit... slow to render changes sometimes.
Sometimes it needed a bit of a kick to look at the styles again and
re-layout the page. After a change (that Safari didn't recognise at
once) I used to do something like this:

  $('body').addClass('dummyClass').removeClass('dummyClass');

And it would work. YMMV.

You could try disabling the link before removing it.

Karl Rudd

On Sat, Feb 14, 2009 at 2:13 AM, Olaf Gleba l...@creatics.de wrote:

 I was wrong. The removal works. But it seems, that clicking on a link which
 removes the DOM link tag doesn't affect the browser rendering. So the DOM
 link tag is removed, but i still get a unaltered pageview.

 This regards to Safari Mac and also IE 7 Win.

 On FF 2/3 (Mac, Win) all is fine: Clicking on a link to reset the pageview,
 the appropriate link tag is removed from the DOM AND the styles of the
 former appended stylesheet doesn't affect the pageview no longer.

 Thanks for your help.

 bye
 Olaf


 Am 13.02.2009 um 13:05 schrieb Karl Rudd:


 If the removal really doesn't work you could try disabling the link.
 $(linkHere).attr('disable',true).

 Karl Rudd

 On Fri, Feb 13, 2009 at 7:22 PM, Olaf Gleba l...@creatics.de wrote:

 Hi.

 On a click event i DOM insert (append) a LINK tag into the head.

 var s = document.createElement('link');
 s.href='/gtpls/'+target+'.css';
 s.rel = 'stylesheet';
 s.type = 'text/css';
 s.media = 'screen';
 $('head').append(s);

 There is a link to the  former created DOM Element to set all to
 standard,
 e.g. restores the standard view.

 $('a[rel=default]').click(function() {
  $('HEAD').find('link[href=path-to-css]').remove();
  ...
 });

 Everythings fine except Safari 3.2.1. It seems to find the target link
 tag
 (gives me 1 when i check length), but doesn't remove it on the fly.

 Is that a known issue on safari? Any hints to achive the desired
 behaviour?

 greets
 Olaf

 --
 Olaf Gleba : creatics media.systems
 Tel. +49 (0)221 170 67 224 : Fax. +49 (0)221 170 67 225
 o...@creatics.de : http://www.creatics.de
 PGP-Key http://www.creatics.de/keys/

 Welcompose CMS - Einfach und Effizient
 http://www.welcompose.de








 gruss
 Olaf

 --
 Olaf Gleba : creatics media.systems
 Tel. +49 (0)221 170 67 224 : Fax. +49 (0)221 170 67 225
 o...@creatics.de : http://www.creatics.de
 PGP-Key http://www.creatics.de/keys/

 Welcompose CMS - Einfach und Effizient
 http://www.welcompose.de






[jQuery] Re: Safari and .remove()

2009-02-13 Thread Karl Rudd

If the removal really doesn't work you could try disabling the link.
$(linkHere).attr('disable',true).

Karl Rudd

On Fri, Feb 13, 2009 at 7:22 PM, Olaf Gleba l...@creatics.de wrote:

 Hi.

 On a click event i DOM insert (append) a LINK tag into the head.

 var s = document.createElement('link');
 s.href='/gtpls/'+target+'.css';
 s.rel = 'stylesheet';
 s.type = 'text/css';
 s.media = 'screen';
 $('head').append(s);

 There is a link to the  former created DOM Element to set all to standard,
 e.g. restores the standard view.

 $('a[rel=default]').click(function() {
$('HEAD').find('link[href=path-to-css]').remove();
   ...
 });

 Everythings fine except Safari 3.2.1. It seems to find the target link tag
 (gives me 1 when i check length), but doesn't remove it on the fly.

 Is that a known issue on safari? Any hints to achive the desired behaviour?

 greets
 Olaf

 --
 Olaf Gleba : creatics media.systems
 Tel. +49 (0)221 170 67 224 : Fax. +49 (0)221 170 67 225
 o...@creatics.de : http://www.creatics.de
 PGP-Key http://www.creatics.de/keys/

 Welcompose CMS - Einfach und Effizient
 http://www.welcompose.de






[jQuery] Re: Cannot Get JQuery Ajax to work in Google Chrome browser

2009-02-10 Thread Karl Rudd

It's probably something to do with what Opera and WebKit allow in the
unload handler. In fact doing a Google on opera unload trigger link
turned up these two links:

  
http://objectmix.com/javascript/631919-unload-event-more-restrictive-now-safari-3-1-a.html
  https://bugs.webkit.org/show_bug.cgi?id=19922

Karl Rudd

On Wed, Feb 11, 2009 at 11:49 AM, Mike malonem...@gmail.com wrote:

 Can anyone help me out with this? Here is a version of the update.php
 script which will just write what the info it gets to a log file. I
 found that the ajax works in IE and Firefox, but not on Chrome or
 Opera:

 update.php:

 $debug = true;

  function update_log_event ($filename, $linenum, $message,
 $extra_text=)
  {
 $log_filename   = dirname(__FILE__) . '/update_log.txt';
 $logfile_header = '?php header(Location: /); exit();' . \r
 \n . '/* === Update LOG file === */' . \r
 \n;
 $logfile_tail   = \r\n?;

 // Delete too long logfiles.
 if (file_exists ($log_filename)  filesize($log_filename)
100)
unlink ($log_filename);

 $filename = basename ($filename);

 if (file_exists ($log_filename))
{
// 'r+' non destructive R/W mode.
$fhandle = fopen ($log_filename, 'r+');
if ($fhandle)
   fseek ($fhandle, -strlen($logfile_tail), SEEK_END);
}
 else
{
$fhandle = fopen ($log_filename, 'w');
if ($fhandle)
   fwrite ($fhandle, $logfile_header);
}
 if ($fhandle)
{
fwrite ($fhandle, \r\n//  . date(F j, Y, g:i a). |$filename
 ($linenum)|:  . $message . ($extra_text?\r\n//Extra Data:
 $extra_text:) . $logfile_tail);
fclose ($fhandle);
}
  }

  if ($debug) {
$message = Update Started URL:  . $_POST['location'] . 
 pageTime:  . $_POST['pageTime'] .  Scroll:  . $_POST
 ['pageScroll'] . \n;
update_log_event (__FILE__, __LINE__, $message, $extra_text=);
  }


 On Feb 10, 2:09 am, Mikedeezy33 malonem...@gmail.com wrote:
 I have a piece of code that updates a script with the page scroll and
 time on page when the user closes the page. I have this working in
 Firefox and IE, but it will not work in Chrome. Chrome will calculate
 the values correctly in jscript, but it will not post to the script. I have
 narrowed down the problem to being in the JQuery call to the ajax
 function. Does anyone know what I am doing wrong here?

 var maxScroll = 0;
 var pageOpen = new Date();
 var currentURL = window.location;
 var updateURL = /wp-content/plugins/extra-tracking/update.php;
 var intervalUpdate = false;

   if (intervalUpdate) {
 setInterval( update, 15000);
   }

   jQuery(window).scroll(function(){
   scrollPercent = Math.floor(jQuery(window).scrollTop() / ( jQuery
 (document).height() - jQuery(window).height() ) * 100 );
   if (scrollPercent  maxScroll) {
  maxScroll = scrollPercent;
   }
   });

   function update() {
 time = pageTime();
 temp = jQuery.ajax({
   type: POST,
   url: updateURL,
   data: pageScroll=+maxScroll+pageTime=+time
 +location=+currentURL
   //success: function(msg){ alert(Page time:  + time +  Page
 Scroll  + maxScroll); }
   });
 return false;
   }

   function pageTime() {
 curTime = new Date();
 minutes = (curTime.getMinutes() - pageOpen.getMinutes());
 seconds = (curTime.getSeconds() - pageOpen.getSeconds());
 time = (seconds + (minutes * 60));
 if (time  0) { time = 0; }
 return time;
   }

 jQuery(window).unload( function ()
   {
  endTime = pageTime();
  temp = jQuery.ajax({
   type: POST,
   url: updateURL,
   data: pageScroll=+maxScroll+pageTime=+endTime
 +location=+currentURL
   //success: function(msg){ alert(Page time:  + time +  Page
 Scroll  + maxScroll); }
   //error: function (xhr, desc, exceptionobj) { alert
 (xhr.responseText); }
   });
   } );


[jQuery] Re: Increment Value. What am I doing wrong?

2009-02-10 Thread Karl Rudd

Remember also that .val() will return a string, so you'll need to
convert it to a number first (parseInt), then decrement it.

Karl Rudd

On Wed, Feb 11, 2009 at 1:14 PM, brian bally.z...@gmail.com wrote:

 $index.val() returns the value. $index.val(VALUE); assigns VALUE.

 So, this should (might) work:

 $index.val(--$index.val())

 It doesn't look so great, though. I say might because I'm not sure
 if that needs to be set as a var, first.

 You also want the decrement on the left or you'll be decrementing the
 value after you assign it, where the decrement will not have any
 effect (because the pre-decremented value was assigned).



 On Tue, Feb 10, 2009 at 9:07 PM, shapper mdmo...@gmail.com wrote:

 Hello,

 I have an input on my page as follows:

  input id=Index name=Index type=hidden value=0 /

 I am trying to increase and decrease the value of the input as
 follows:

$index = $('#Index');
$index.val()--;

 I always get an error:
 invalid assignment left-hand side

 What am I doing wrong?

 Thanks,
 Miguel





[jQuery] Re: test for css selector capability?

2009-02-09 Thread Karl Rudd

You could do this because the .css(attribute) returns the computed
(the result of all the CSS applied) value of an element's CSS
attribute.

It would involve adding a stylesheet to the document with the
particular selector in it, with say a change to the background colour.
Then create elements that should be selected (and add them to the
document), then test the .css('background-color') of the element to
see if it matches the colour in the stylesheet.

Slightly tricky but doable.

Karl Rudd

On Tue, Feb 10, 2009 at 10:31 AM, Geuis geuis.te...@gmail.com wrote:

 I guess this really is a hard concept to get across after all.

 Ok, so there's browser feature detection with .support.

 So imagine the thing I'm talking about works like this:

 alert( $('ul li:first-child').support );

 alerts 'true' if Firefox, but alerts 'false' if IE6.

 I'm not trying use the selectors to do styling, I'm trying to use the
 selectors to detect browser capability.


 On Feb 9, 2:50 pm, MorningZ morni...@gmail.com wrote:
 Are you *sure* that parent  child doesn't work in IE6?

 I could see that this CSS declaration, and pretty sure it doesn't work

 ul  li {
  color: blue;

 }

 but part of the magic of jQuery (and other libraries) is that it takes
 that into account already. and saying $(ul  li) should work no
 matter what (supported) browser it runs on

 On Feb 9, 5:33 pm,Geuisgeuis.te...@gmail.com wrote:

  I think my question was misunderstood. I'm not asking about detecting
  browser versions.

  I want to test if the current browser has native support for a
  particular kind of CSS selector. My previous example was the :first-
  child pseudo selector that isn't supported in IE6, but is supported in
  most other browsers. Another example would be ul  li, which selects
  only li elements that are immediate children of a ul.

  Anyone have some ideas on how this could be implemented?

  On Feb 9, 7:16 am, Aaron Gundel aaron.gun...@gmail.com wrote:

   jQuery.browser is deprecated in 1.3 + (don't use it).

   JQuery now uses feature detection.  This is a more extensible way of
   detecting which browser is being utilized.

   See the following page for more 
   details...http://docs.jquery.com/Utilities/jQuery.support

   On Mon, Feb 9, 2009 at 4:02 AM, Mohd.Tareq tareq.m...@gmail.com wrote:

HiGeuis,

Ther is a function with alias ($.browser) it will gives u 
functionality to
identify browser name
like this $.browser.mozilla , $.browser.msie , $.browser.opera 
,
$.browser.safari.
 if u wana return the version of browser , then u have use below 
function
$.browser.version it will return version of current browser according 
to ur
problem ie6 u can add css on the fly.

hope this will work .

cheers  cioa

On Mon, Feb 9, 2009 at 11:47 AM,Geuisgeuis.te...@gmail.com wrote:

I'm working on a project where I need to detect if the browser
natively supports a given CSS selector.

For example, if I am using the selector 'ul li:first-child', this is
supported by IE7, FF, and Safari but not by IE6 and below. Is there a
way that I can test that selector to see if the current browser
supports it? A feature that returns a simple boolean status would be
awesome.

--
---| Regard |---

Mohd.Tareque


[jQuery] Re: How to save this context in callbacks

2009-02-07 Thread Karl Rudd

Assign this to a local variable.

function blah() {
  var blahThis = this;
  someExternalFunction( function() {
   blahThis.doSomething();
  }
}

Karl Rudd

On Sun, Feb 8, 2009 at 9:28 AM, Alexander kayuch...@gmail.com wrote:

 Goodday!
 Could anyone tell me how to save this context inside callback?
 Here is simple example:

 var myClass = jQuery.Class.create({
init: function(){
this.value = value;

// callback as argument:
someExternalFunction( function() {
this.setValue(); // PROBLEM: this is not 
 myClass pointer
 anymore!
} );
},

setValue: function () {
this.title = new value;
}
 });



[jQuery] Re: How to save this context in callbacks

2009-02-07 Thread Karl Rudd

Sorry, cut and paste error there. Corrected:

function blah() {
 var blahThis = this;
 someExternalFunction( function() {
  blahThis.doSomething();
 });
}

Karl Rudd

On Sun, Feb 8, 2009 at 12:03 PM, Karl Rudd karl.r...@gmail.com wrote:
 Assign this to a local variable.

 function blah() {
  var blahThis = this;
  someExternalFunction( function() {
   blahThis.doSomething();
  }
 }

 Karl Rudd

 On Sun, Feb 8, 2009 at 9:28 AM, Alexander kayuch...@gmail.com wrote:

 Goodday!
 Could anyone tell me how to save this context inside callback?
 Here is simple example:

 var myClass = jQuery.Class.create({
init: function(){
this.value = value;

// callback as argument:
someExternalFunction( function() {
this.setValue(); // PROBLEM: this is not 
 myClass pointer
 anymore!
} );
},

setValue: function () {
this.title = new value;
}
 });




[jQuery] Re: Using selectors successfully...?

2009-02-07 Thread Karl Rudd

That should work fine. Example: http://jsbin.com/odada

Something else must be going wrong.

Karl Rudd

On Sun, Feb 8, 2009 at 2:07 PM, gberz3 gbe...@gmail.com wrote:

 Will someone please explain to me why the following code fails to
 execute?  I have a simple test page set up and jquery doesn't seem
 happy with what I'm trying to do.  I get no errors, and when I log to
 console in firebug it shows that it is indeed finding my two objects,
 however it won't actually perform 'addClass':


$(document).ready(function() {

$(.testclass).each(function(){
$(this).addClass(midget);
});
});




 At first I just figured it was because I wasn't doing an each, but
 then after trying each and having it still fail, I was back to square
 one.  Also, is it not possible to select based on tags (e.g.
 'div.divclass')?

 Any help would be much appreciated.


 Best!



[jQuery] Re: How to detect jQuery version?

2009-02-05 Thread Karl Rudd

jQuery.fn.jquery

Karl Rudd

On Fri, Feb 6, 2009 at 11:54 AM, Geuis geuis.te...@gmail.com wrote:

 Wondering what an easy way to detect which version of jQuery is
 running on a page. Is there a $.version property? Doing feature
 detection based on deprecated methods probably wouldn't work well,
 since they would still exist in some newer versions.


[jQuery] Re: how to access checked attribute on a toggle

2009-02-04 Thread Karl Rudd

The name attribute isn't the same as the id attribute (though in
IE it kind of is).

On a side note, XHTML and HTML differ in how you make something checked:

HTML:
  input type=checkbox checked

XHTML:
  input type=checkbox checked=checked

If you want to select by name you'll need to do this:

  $(input[name=tog_0])

Or you could add an id to the checkboc it if you want:

  input class=show_tog type=checkbox checked=checked id=tog_0
name=tog_0/

Then your $(#tog_0).attr('checked') will work.

On a side note, jQuery (or $) always return a jQuery object. To check
to see if that object (it acts a bit like an array) actually
contains anything check it's length. That is:

  if ( $('#something').length ) {
// an object with id=something exists on the page
  }

Karl Rudd

On Thu, Feb 5, 2009 at 12:02 PM, Chris chris.b...@gmail.com wrote:

 This is incredibly basic, but I'm missing something. I have this html:

 input class=show_tog type=checkbox checked=  name=tog_0/

 I want to find the toggle and get the value of checked. I have tried
 the following, but nothing works:

 alert ($(#tog_0).attr(checked));
 alert ($(#tog_0).checked);

 both give me undefined.

 $(#tog_0) is giving me an object.

 What am I missing?

 --
 Chris



[jQuery] Re: Detecting wether an image link is going to work

2009-02-03 Thread Karl Rudd

You could try using the error handler:

  $(image[1]).bind('error', function(){ /* ... */ });

I believe it works for all the common browsers.

Karl Rudd

On Wed, Feb 4, 2009 at 5:41 AM, daveJay davidjo...@exit42design.com wrote:

 I've got a page set up where it loads each image on the page, one
 after the other. As you can see here:

 http://sandbox.exit42design.com/photography/folio_1.html

 The problem with this is that if one of the images is broken, it'll
 stop in it's tracks and not try to load the next.

 Here's an example of how I'm loading the images

 $(image[1]).load(function(){
$(#image1).attr({src : image[1].src});
image[2].src= path/to/next/image.jpg;
 });

 $(image[2]).load(function(){
$(#image2).attr({src : image[2].src});
image[3].src= path/to/next/image3.jpg;
 });

 So, basically when the first one is loaded, it inserts it onto the
 page, and then sets up the next image path, and so on and so on. So I
 need a way to detect if image 2 is going to load successfully, because
 if it can't image 3 will never be allowed to load.

 I tried using an ajax call but I'm not terribly familiar with how to
 use it, for example, in an if statement. Can I get this ajax call to
 just return a yes or no value of wether or not there was an error or
 not?
 $.ajax({url:imagesSrc[1], type:'HEAD', error:somefunction})

 Thanks for any help. And any other comments/bug reports on the site
 are welcome as well =)





[jQuery] Re: Manipulating form field attributes

2009-02-03 Thread Karl Rudd

IE doesn't allow you to change the type of a form element once it's created.

Best solution is to create a new element and add in the value and
name, then delete the old element.

Karl Rudd

On Wed, Feb 4, 2009 at 9:17 AM, Sam Hastings sam.hasti...@gmail.com wrote:

 Hi everyone,

 I'm trying to use the following code to change input type=text /
 to input type=hidden / where the element has the classname
 navtitle.

$(.navtitle).each(function() {
this.type = hidden;
});

 This code works fine in Firefox but has no effect at all in IE. Can
 anyone help me please?

 Sam Hastings



[jQuery] Re: failing .click() trigger on element created using .replaceWith()

2009-02-02 Thread Karl Rudd

You are correct. If you replace an element then any handlers
attached to it will be removed.

When you say $('p').click( handleClick ) the handleClick function is
_only_ attached to the currently existing p elements. If you add
more elements later (or remove and replace an existing element), the
handleClick function won't be attached to those new elements.

There are a few solutions:
- manually attach the handler to new elements
- use the liveQuery plugin ( http://plugins.jquery.com/project/livequery/ )
-  if you're using jQuery 1.3.1 you can look at the new live
function ( http://docs.jquery.com/Events/live )

More information here:
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_..._.3F

Karl Rudd

On Mon, Feb 2, 2009 at 10:43 PM, NekraNoX
rob...@internetessentials.co.uk wrote:

 Hey guys,

 Simple problem, really can't see what's wrong with it though:

 http://internetessentials.co.uk/clients/ashmoors/products.html

 Click Specifications on the sub-nav (middle-right of page) and see
 how the content area is changed using show/hide and the links in the
 sub-nav are modified so that Specifications is no longer and link
 but Furniture detail is.

 The idea is that we want Furniture details and Specifications to
 be toggeled with JQuery. The other links to go to separate pages.

 The problem is, if you click Furniture details after clicking
 Specifications it doesn't trigger the .click() event.

 I'm wondering if this is because the object has been modified since
 the page load and can't been effected by the original function
 anymore. Any ideas?

 Thanks very much!



[jQuery] Re: Sending Arguments to Event

2009-01-28 Thread Karl Rudd

If you look at the examples in the bind documentation (
http://docs.jquery.com/Events/bind ) there's this sample:

function handler(event) {
  alert(event.data.foo);
}
$(p).bind(click, {foo: bar}, handler)

So for your example that could be:

var someVar = {
   init : function () {
   $('#someID').bind(click, {'args': ['arg1', 'arg2']}, this.add);
   },
   add : function(event) {
   alert(event.data.args[0] + ' : ' + event.data.args[1]);
   }
};

Karl Rudd

On Wed, Jan 28, 2009 at 5:12 PM, Anjanesh anjanesh.for...@gmail.com wrote:

 I understand jQuery has parameters stored in event.data.*
 But Is there a way to achieve this using jQuery ?

 var someVar = {
init : function () {
$('#someID').bind(click, ['arg1', 'arg2'],
 this.add);
},
add : function(p1, p2) {
alert(p1 + ' : ' + p2); // Doesnt show arg1 : arg2
}
 };

 Thanks


[jQuery] Re: Need access to index within loop

2009-01-22 Thread Karl Rudd

You don't have to select the LI again. Within the each function
the this variable refers to the LI DOM node. So you can write:

$(document).ready(function(){
  $('li').each(function(i) {
alert(i);
$(this).fadeIn('slow');
  });
});

Karl Rudd

On Thu, Jan 22, 2009 at 9:41 PM, elduderino jamesfiltn...@gmail.com wrote:


 HI,

 I have this code:

   $(document).ready(function(){

  $('li').each(function(i) {
  alert(i);
  $('li:eq(i)').fadeIn('slow');
  });

  });

 I want to iterate over each li element and fade it inwith a delay for
 each onei'll deal with the delay in a bit but currently the problem is
 this bit  $('li:eq(i)')it won't accept the i parameter...it wants a
 literal numberhow do I do this?

 --
 View this message in context: 
 http://www.nabble.com/Need-access-to-index-within-loop-tp21601683s27240p21601683.html
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: New 1.3 feature, native event delegation??

2009-01-22 Thread Karl Rudd

Event delegation and adding event handlers to new elements are
actually two different things.

The event delegation works without any changes. So if you put a
click event on a table and click a td then the table's click event
will be triggered too.

The automatic event handler adding uses the live and die functions:

  http://docs.jquery.com/Events

Karl Rudd

On Fri, Jan 23, 2009 at 10:11 AM, Sam H samh1...@gmail.com wrote:

 John Resig said of 1.3:

 I only posted last week about how event delegation can help you to
 optimize your code and it looks like jQuery will do it for you now,
 which means that any event handlers you add to a group of elements
 will automatically be added to matching elements when you create
 them.

 Yet I'm not seeing this functionality.  Within my $(document).ready()
 func, I do this:

  $('.do_it').click(function() { ...stuff... });

 Yet if I dynamically create new items using class=do_it, the above
 function is not automatically attached to them.  I have to once again,
 after dynamically creating new items, perform the $('.do_it').click()
 again.

 I thought 1.3 was supposed to eliminate this.  Am I doing something
 wrong?


[jQuery] Re: How do I communicate with other windows with jquery

2009-01-22 Thread Karl Rudd

If the tab was a window opened via window.open then you should be
able to access it like any other window opened like that. For instance
(untested):

var myWindow = window.open('blah.html');
$('body', myWindow.document).addClass('something');

Note you have to put the context (myWindow.document), otherwise
jQuery will use the current window's document as the base for it's
selections.

Karl Rudd

On Fri, Jan 23, 2009 at 2:12 PM, jack datac...@gmail.com wrote:

 On firefox mutiple tabs, how do I manipulate the other tabbed window,
 such as set focus or change css on a specific element?


[jQuery] Re: global events??? actions on multiple forms

2009-01-21 Thread Karl Rudd

There are a few ways. Have a read of this:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F

Karl Rudd

On Thu, Jan 22, 2009 at 9:26 AM, phanorcoll phanorc...@gmail.com wrote:

 hi,

 i have the following code:

 $(function() {
$('.error').hide();
$('input.text-input').css({
backgroundColor:#FF
});
$('input.text-input').focus(function(){
$(this).css({
backgroundColor:#FFDDAA
});
});
});
  
  
  
 });
  it works fine with the form on in index.php,which its not loaded
 using ajax, but whe i load another form using ajax, those events stop
 working. is there a way to have global events so that every form,
 whether its loaded using ajax or not, can use them??



[jQuery] Re: multiple submit sends with CSS Button

2009-01-21 Thread Karl Rudd

Rick, I don't think Ricardo meant to be damning. Your response was a
bit harsh. Perhaps English isn't his native language, or perhaps he
typed his response in a rush without thinking about the wording.

I find that I think the best of people's motives and it makes things a
lot easier (and it's usually right). Fighting fire with fire just
leaves more burnt.

Anyway, back on topic...

Karl Rudd

On Thu, Jan 22, 2009 at 9:37 AM, Rick Faircloth
r...@whitestonemedia.com wrote:

 that's a useless pice (sic) of code

 Can't you think of a less damning way to that, Ricardo?

 Perhaps, I'm not sure what your code is supposed to do.  What does
 the trigger_form_submit() function do?  And I don't see where
 any jQuery fits into your code.

 See how nice that sounds and still gets across your point.

 How old are you Ricardo?  You must be about 20 to so young and arrogant
 in your remarks toward others.  You should be glad you don't get
 treated that way by others who know more than you.

 Lighten up on people!

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Ricardo Tomasi
 Sent: Wednesday, January 21, 2009 4:54 PM
 To: jQuery (English)
 Subject: [jQuery] Re: multiple submit sends with CSS Button


 that's an useless pice of code, what does the trigger_form_submit()
 function do, and where is jQuery in that?

 On Jan 21, 4:19 pm, Robert kont...@robert-natus.de wrote:
  Hi,
 
  i have a Problem with a CSS-Button. Evertime when I click the Button,
  the formular will be send three times.
 
  A normal input submit button does the same task exactly one time.
 
  Here is my Code for this Button (only the first button is important,
  Abort Button works fine at it is). jqeury 1.2.6 is included
 
  div class=buttonleiste
a style=float: left; margin-right: 10px;
  onclick=trigger_form_submit(this, 'ok') id=
   class=button_ok button_all href=javascript:;span
  class=buttonLogin/span/ainput
type=submit style=display: none; name=button[ok]/
 
a style=float: left; margin-right: 10px;
  onclick=trigger_form_submit(this, 'abort') id=
   class=button_abort button_all href=index.phpspan
   class=buttonAbort/span/ainput type=submit
  style=display: none; name=button
 [abort]/
  /div
 
  Thanks for your help




[jQuery] Re: multiple submit sends with CSS Button

2009-01-21 Thread Karl Rudd

Robert,

We need to see the code for the trigger_form_submit function before
we can understand what is going wrong.

Karl Rudd

On Thu, Jan 22, 2009 at 9:47 AM, Robert kont...@robert-natus.de wrote:

 A normal form with login and password.

 I included jquery in my functions file, so its everywhere included.
 jquery should handle the trigger? I don't use jquery and CSS
 normally. But I have to include the CSS and the trigger doesn't submit
 without jquery.


 Here is the whole code of the form, nothing special:

  form name =login action=functions/login.php method=post
 id=form
 fieldset
legendLogin/legend
div class=formelement
label 
 for=loginLoginname:/label

input class=long 
 type=text name=login id=login
 value=Kundennummer tabindex=1 /

/div
br /
div class=formelement
label 
 for=passPasswort:/label
input class=long 
 type=password name=pass id=pass
 value= tabindex=2 /
/div
br /

br /
/fieldset
br /
input type=submit value= 
 Absenden 

  div class=buttonleiste
a style=float: left; margin-right: 10px;
 onclick=trigger_form_submit(this, 'ok') id= class=button_ok
 button_all href=javascript:;span class=buttonEinloggen/span/
 ainput type=submit style=display: none; name=button[ok]/
a style=float: left; margin-right: 10px;
 onclick=trigger_form_submit(this, 'abort') id= class=button_abort
 button_all href=index.phpspan class=buttonAbbrechen/span/
 ainput type=submit style=display: none; name=button[abort]/
  /div/form


[jQuery] Re: Unexpected DOM layout changes in IE6+

2009-01-20 Thread Karl Rudd

Most likely this has nothing to do with jQuery. IE is rather brittle
in the way it lays out a page. Sometimes it forgets to update the
layout.

Sometimes you can jog its memory by making it refresh the whole
page's layout. For instance in this case add the following code as the
last line in your document.ready function:

$('body').addClass('blah').removeClass('blah');

And everything works.

*shrug* That's IE for you.

Karl Rudd

On Wed, Jan 21, 2009 at 3:33 PM, SteveBroski stevebro...@gmail.com wrote:

 I'm not sure if this is a bug (known or unknown), but examples can be
 seen at:

 http://www.sportsamerica.com/testjquery/withJSh2.html

 Whoops... that link was one of the tests.

 Real URL:
 http://www.sportsamerica.com/testjquery/


[jQuery] Re: Conflict with Mootools...

2009-01-19 Thread Karl Rudd

Have you checked out the documentation?:

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Karl Rudd

On Tue, Jan 20, 2009 at 8:40 AM, Erik R. Peterson eriks...@mac.com wrote:

 I have a lot of jquery scripts in my html and I just added a mootools
 script.

 Now none of my jquery scripts don't work.


 script type=text/javascript src=/src/js/rssticker.js/script
 script type=text/javascript src=/src/js/slideshow.js/script
 script type=text/javascript
 src=/src/js/jquery/lavalamp/jquery-1.2.3.min.js/script
 script type=text/javascript
 src=/src/js/jquery/lavalamp/jquery.easing.min.js/script
 script type=text/javascript
 src=/src/js/jquery/lavalamp/jquery.lavalamp.min.js/script
 script type=text/javascript
 src=/src/js/jquery/jquery-1.2.6.min.js/script
 script type=text/javascript
 src=/src/js/jquery/jquery.labelify.js/script


 script type=text/javascript charset=utf-8
 src=/src/js/mootools/barack/barackslideshow.js/script
 script type=text/javascript charset=utf-8
 src=/src/js/mootools/barack/demo.js/script
 script type=text/javascript charset=utf-8
 src=/src/js/mootools/1.2.1/core.js/script
 script type=text/javascript charset=utf-8
 src=/src/js/mootools/1.2.1/more.js/script
 script type=text/javascript charset=utf-8
 src=/src/js/mootools/barack/morphlist.js/script




 I need help.

 Can someone show me how to use the noconflict script.

 Many thanks.

 Erik





[jQuery] Re: New link being ignored by jQuery

2009-01-19 Thread Karl Rudd

Check out the documentation for several solutions:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_..._.3F

Karl Rudd

On Tue, Jan 20, 2009 at 5:14 AM, Mark MacInnes
markamacin...@googlemail.com wrote:

 I'm using jQuery to perform some ajax when a link with a certain id is
 clicked on. The ajax updates a database record and then it replaces
 the 'a' tag with a new one. This all works fine. The new 'a' tag has
 the same id as the old one, but text and some other properties on it
 change. It's the id that activates the jQuery functionality.

 When the old 'a' tag is replaced with the new one the jQuery that
 should operate doesn't work. I understand that this is because the new
 'a' tag has been added after the page loaded so jQuery doesn't know to
 fire when it's clicked on. Is there anything I can do that will force
 jQuery to fire when the new 'a' tag is clicked?

 I suspect this has probably been answered a million times, but I don't
 just can't find the right search terms.



[jQuery] Re: newby... cannot get $(div).length; to work

2009-01-18 Thread Karl Rudd

The code is being run before the DIVs actually exist. You need to
wrap the code in a ready event handler, like so:

$(document).ready( function() {
   var divcount = $(div).length;
   alert(start= + divcount);
});

Now the code will be run when the document (the HTML not images, etc)
has finished loading and is ready.

More info about the ready function/event here:

   http://docs.jquery.com/Events/ready#fn

Karl Rudd

On Mon, Jan 19, 2009 at 12:45 PM, bartee bar...@gmail.com wrote:

 I have this test code.  My alert dialog always show zero as the div
 count:

 Help !!!

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en-AU
 head
  titleJquery Test/title
  script type=text/javascript src=jquery-1.3.js/script
  script type=text/javascript
var divcount = $(div).length;
alert(start= + divcount);
  /script
 /head
 body
 div id=content
  div id=div2asdf/div
  div id=div2asdf/div
 /div
 /body
 /html



[jQuery] Re: namespacing events

2009-01-15 Thread Karl Rudd

I think it's working as designed. If you're trying to trigger
my.event then regardless of whether it's a my.event in the a or
the b namespace it should be triggered.

If you think about it with normal events:

$('#button').bind('click', function(){ /* ... */ });
$('#button').bind('click.mySpace1', function(){ /* ... */ });
$('#button').bind('click.anotherNameSpace', function(){ /* ... */ });

// This should trigger all 3 functions
$('#button').trigger('click');

Karl Rudd

On Thu, Jan 15, 2009 at 9:15 PM, Stephan stephan.ve...@gmail.com wrote:

 Hi,

 I have problems with namespacing my events. When I use something like
 my.event everything works fine, but if I have my.event.a and
 my.event.b, both events are bound to my.event.

 Is this a bug or a special feature?


 my test code:

 JavaScript:
var trigger = 0;
var clicked = 0;

$().bind(my.event.a, function() {
$(#trigger).text(++trigger);
});

$(#button).click(function(){
$().trigger(my.event.a);
$().trigger(my.event.b);
$().trigger(my.event.c);
$(#click).text(++clicked);
});

 HTML:
pTrigger Count: span id=trigger0/span/p
pButton Clicked: span id=click0/span/p
button id=buttontrigger/button

 When you press the button, clicked is increased by 1, but trigger is
 increased by 3.


 by(e)
 Stephan




[jQuery] Re: In this code, what would $(this) in the success part refer to?

2009-01-14 Thread Karl Rudd

Rick, while I can appreciate your unhappiness Matt and MorningZ,
responding doesn't help anyone.

Let's leave thread alone now. Or if need be perhaps you guys can take
it to personal emails.

Karl Rudd
(not a moderator, just someone who prefers quiet discussion) :)

On Thu, Jan 15, 2009 at 10:47 AM, Rick Faircloth
r...@whitestonemedia.com wrote:
 Matt…



 I defy you to find references to where I've asked about the same topic

 more than a few times, especially over years.  I haven't even been on

 the list that long.  And where, even once, have I asked someone to write

 code for me?  Never, except for examples as guides…



 And if you'll look back over the last couple of threads you're alluding to,

 you'll find two completely different situations concerning the use of
 $(this).



 No one has asked you, specifically to answer *any* questions, and if you
 don't

 want to be of assistance, even to those who may ask something over and

 over again (which I have not), then just answer the ones you like.



 But you are not the list moderator and have no business attempting to
 control

 how anyone interacts with this list.  And I doubt we'll find it in the list

 guidelines that everyone has to conduct themselves in manner that is
 pleasing

 to Matt Quackenbush.  So help when you want and the rest of the time, just
 shut up. :o)



 Rick



 PS – And if you offered quality assistance to those who ask questions, they

 would learn from your help…





 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
 Behalf Of Matt Quackenbush
 Sent: Wednesday, January 14, 2009 5:46 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: In this code, what would $(this) in the success part
 refer to?



 Just to be clear, I'm kinda doubting that anyone has an issue with n00b
 questions.  I believe what people take exception to is the exact same person
 asking the exact same type of questions over and over and over and over
 again (for years, even), with the expectation of someone else writing all of
 the code for them, rather than learning from the help they've received. ;-)


[jQuery] Re: [ TR.click not work in Firefox]

2009-01-14 Thread Karl Rudd

Trying changing:

  x.css(background-color,ee);

to:

  x.css(background-color,#ee);

Karl Rudd

On Thu, Jan 15, 2009 at 10:15 AM, Lord Gustavo Miguel Angel
goosfanc...@gmail.com wrote:
 hi,

 Look this do not work in firefox, in IE yes. why?

 Thank´s


 -- index.html -

 !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 /

 script language=javascript type=text/javascript
 src=jvs/jquery-1.2.6.js /script
 script language=javascript type=text/javascript
 src=jvs/funciones.js/script

 titleDocumento sin tiacute;tulo/title

 /head

 body

 table width=200 border=1
   tr
 tdt1 c1/td
 tdt1 c2/td
 tdt1 c3/td
   /tr
   tr
 tdt2 c1/td
 tdt2 c2/td
 tdt2 c3/td
   /tr
   tr
 tdt3 c1/td
 tdt3 c2/td
 tdt3 c3/td
   /tr
 /table

 /body

 /html
  EOF ---

 -funciones.js---
 // JavaScript Document
 var x;
 x=$(document);
 x.ready(inicializarEventos);

 function inicializarEventos()
 {
   var x;
   x=$(tr);
   x.click(presionFila);
 }

 function presionFila()
 {
   var x;
   x=$(this);
   x.css(background-color,ee);
 }
 - EOF 


[jQuery] Re: The new core LIVE.

2009-01-14 Thread Karl Rudd

Yes.

Karl Rudd

On Thu, Jan 15, 2009 at 3:10 PM, Ami aminad...@gmail.com wrote:

 The new core LIVE.

 Hello.
 Can I use a namespace with live?
 $.live('click.fuc1',function1 };
 $.live('click.fun2');

 $.die('click.func1');



[jQuery] Re: Standards box model

2009-01-14 Thread Karl Rudd

That will work, but you do not need to change to using XHTML. You
could use HTML Strict:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;

More information here:
  http://en.wikipedia.org/wiki/Quirksmode

Karl Rudd

On Thu, Jan 15, 2009 at 3:08 PM, Ami aminad...@gmail.com wrote:

 Hello,
 Sorry about my grammar, English isn't my tang.

 I read in the Jquery 1.3:release notes, that I must use W3c standards
 mode.
 I tried to understand what it's mean.

 Now my HTML start like that:
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//ENhtml
 dir=rtl


 DO I need to replace it to this: (Like in Jquery website)
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;


 Thank you.



[jQuery] Re: updating flash after changing flashvars

2009-01-14 Thread Karl Rudd

No idea why. You should be able to work around it by setting the
FlashVars attribute directly:

  $(#playersettings)[0].FlashVars = color=00;

Karl Rudd

On Thu, Jan 15, 2009 at 10:11 AM, EugeneS seuge...@gmail.com wrote:

 Hello,

 i have embed flash element on the page
 it looks like
 embed id=flashsettings src=something.swf quality=high
 wmode=transparent FlashVars=color=FF  

 if i'm trying to change the FlashVars with new value it doesnt seem to
 be working but i see that new values was implemented

alert($(#playersettings).attr(FlashVars));
$(#playersettings).attr(FlashVars, color=00);
alert($(#playersettings).attr(FlashVars));

 if i'm trying to change code manually in FireBug i see that Flash
 color canged ... but by means of Jquery it doesnt work ... why ?

 any ideas how to make it working ?

 Thanks.



[jQuery] Re: Standards box model

2009-01-14 Thread Karl Rudd

Try it and see what Internet Explorer 6 does.

Karl Rudd

On Thu, Jan 15, 2009 at 3:53 PM, Ami aminad...@gmail.com wrote:

 So you for you fast answer.
 5 point
 (:

 Do I must to change all my pages from Transitional to strict?
 Or can I leave it as Transitional
 (I afraid from CSS bugs, so i don't want to cahnge)

 On 15 ינואר, 06:48, Karl Rudd karl.r...@gmail.com wrote:
 That will work, but you do not need to change to using XHTML. You
 could use HTML Strict:

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;

 More information here:
  http://en.wikipedia.org/wiki/Quirksmode

 Karl Rudd



 On Thu, Jan 15, 2009 at 3:08 PM, Ami aminad...@gmail.com wrote:

  Hello,
  Sorry about my grammar, English isn't my tang.

  I read in the Jquery 1.3:release notes, that I must use W3c standards
  mode.
  I tried to understand what it's mean.

  Now my HTML start like that:
  !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//ENhtml
  dir=rtl

  DO I need to replace it to this: (Like in Jquery website)
   !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

  Thank you.


[jQuery] Re: Select all controls of the form

2009-01-13 Thread Karl Rudd

You shouldn't need to use $.extend in this case. Something like this
should work:

jQuery.fn.debug = function() {
  return this.each(function(){
alert(this);
  });
};

Taken from http://docs.jquery.com/Plugins/Authoring

As for your selection code, you need to use find instead of
filter. The filter removes non-matching elements, if you pass in a
form element then it won't do what you want. The find function
works on the child elements of the given elements, which is what you
want.

Karl Rudd

On Tue, Jan 13, 2009 at 7:17 PM, JQueryProgrammer
jain.ashis...@gmail.com wrote:

 I want to convert some existing code from traditional javascript for
 loop to $.each. Here is my code:

 var oEl = document.getElementById(my_form_id).elements;

 for(var i=0; i  oEl.length; i++) {
 //do something
 }

 In jquery I have written a $.fn.extend function and the code as:

 $.fn.extend({
test: function() {

//I want to filter only input controls from hte form
var $this = $(this).filter(:input);

$.each($this, function() {
//do something
});
}
 })

 $(#my_form_id).test();

 But it is not working.

 On Jan 13, 12:05 pm, Karl Rudd karl.r...@gmail.com wrote:
 Errr img elements aren't form controls. input type=image
 elements are but :input selects those. I'm not sure what you mean.

 Karl Rudd

 On Tue, Jan 13, 2009 at 5:43 PM, JQueryProgrammer

 jain.ashis...@gmail.com wrote:

  The above code selects all the controls except img tag.

  On Jan 13, 11:26 am, Karl Rudd karl.r...@gmail.com wrote:
  The '*' selector will select _all_ the nodes (including the br/s).
  Try using the ':input' selector:

  $(#form1 :input)

 http://docs.jquery.com/Selectors

  Karl Rudd

  On Tue, Jan 13, 2009 at 5:16 PM, JQueryProgrammer

  jain.ashis...@gmail.com wrote:

   I am trying to validate all the controls that exist in the form. My
   form code looks like:

   form id=form1
  input type=text id=txt1 name=txt1 /
  br/
  textarea name=txtArea id=txtArea cols=100 rows=4 /
  br/
  select id=sel1 name=sel1 style=width: 250px; 
  option value=Select/option
  option value=1One/option
  option value=2Two/option
  option value=3Three/option
  /select
  br/
  input type=radio id=rdo1 name=rdo1
   value=Option1nbsp;Option 1nbsp;
  br/
  input type=radio id=rdo2 name=rdo1
   value=Option2nbsp;Option 2nbsp;
  br/
  button id=btn1Submit/button
  button id=btn2Reset/button
   /form

   I want to select only the controls of the form viz: textbox, textarea,
   select, radio  button (Total 7). I am trying to extract them as

   $(#form1 *).each(function() {
   alert($(#+this).attr(id));
   })

   it gives me total 16 alerts. I want just 7. Any help..?


[jQuery] Re: wild card $('d...@id^=x_div_]') question

2009-01-13 Thread Karl Rudd

Inside an each called function the this variable will be each
(raw) element that's in the list.

So to alert the id of each DIV selected:

x = $('div[id^=x_div_]');
x.each( function(i) {
  alert(this.id);
}

Note that it's the raw DOM element, so if you want to do anything
with it using jQuery you need to do $(this).whateverjQueryFunction()

On a side note, don't use the @ anymore. It's been deprecated for a
while and is being removed in the next version of jQuery.

Karl Rudd

On Wed, Jan 14, 2009 at 2:24 PM, ywkyee ywk...@gmail.com wrote:


 hello,

 i am new from jquery and want search a wildcard DIV id pattern
 then with following purpose

 x = $('d...@id^=x_div_]');
 x.each( function(i) {
 alert(this.i);
 }

 i want to display each of DIV id , how can i pass in that parameter?

 Many thanks/Davis.


 --
 View this message in context: 
 http://www.nabble.com/wild-card-%24%28%27div-%40id%5E%3Dx_div_-%27%29-question-tp21449359s27240p21449359.html
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.




[jQuery] Re: In this code, what would $(this) in the success part refer to?

2009-01-13 Thread Karl Rudd

If you check the documentation you'll see that this in the success
function will be the options for this ajax request.

http://docs.jquery.com/Ajax/jQuery.ajax#options

Karl Rudd

On Wed, Jan 14, 2009 at 2:31 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 Would it still be referring to the '.update-button that was clicked in the 
 second line?

 Thanks,

 Rick


 $(document).ready(function() {

   $('.update-button').click(function(){

  var formval   =   { tour_url:   
 $(this).parent().parent().find('.update-input').attr('value'),
  mls_number: 
 $(this).parent().parent().parent().attr('id'),
  dsn:'cfoutput#application.dsn#/cfoutput',
  agent_id:   
 'cfoutput#session.agent_id#/cfoutput' };

  $.ajax({cache: false,
  type: POST,
  url:
 ../components/virtual_tours.cfc?method=update_tour_urlreturnFormat=json,
  dataType: json,
  data: formval,
  success: function(response) {

 if (response.update == Update 
 Successful)
   { $(this).attr('id');
 $(this).attr('id'); }
 else
   {
 $(this).parent().next('.tour-url').empty().append('Update 
 Unsuccessful').fadeIn(500); }

  }


  });
   });

 });




[jQuery] Re: In this code, what would $(this) in the success part refer to?

2009-01-13 Thread Karl Rudd

Guys, it's probably a good time for a time out. This is doing no one
any good, least of all those reading the list.

I understand MorningZ and Matt Quackenbush's frustration, I often feel
the same way about a lot of the posts on the list, Rick's included. No
offence intended Rick. I can see that you're trying to do a lot and
are not familiar with JavaScript/CSS, that does lead to a lot of
questions.

Occasionally if the question is read the documentation I'll provide
a link, but more often than not I just ignore them. It leads to a lot
less stress, mostly for me :). Trying to explain quantum physics to
someone who's just learning about gravity is usually a recipe for
stress for all involved.

Karl Rudd

On Wed, Jan 14, 2009 at 3:56 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 I help myself, too, but often times, answers that are offered
 to problems aren't correct, so you'll certainly hear that didn't work
 if you post an incorrect answer to a question.



 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of MorningZ
 Sent: Tuesday, January 13, 2009 11:38 PM
 To: jQuery (English)
 Subject: [jQuery] Re: In this code, what would $(this) in the success part 
 refer to?


 that's exactly the point i was reaching at

 some people, myself included, point out a syntax error in the posted
 code... only to have it changed to as suggested and then a new post of
 that didn't work!...  there's no effort shown to understanding why  $
 (this) and $(this) are two totally different things...  just that
 it didn't work

 the whole underlying problem is a total lack of understanding of
 selectors and what they are getting

 whatever though... i know i am not alone in opening a new topic only
 to see it the same exact post from before  it's just that i'm the
 first person to speak of it  so don't burn me at the stake for
 saying what many others are thinking.   as Matt says, you have to
 help yourself first



 On Jan 13, 11:33 pm, Matt Quackenbush quackfu...@gmail.com wrote:
  Has it ever occurred to you that maybe, just maybe, people are sick and
  tired of helping you when you refuse to help yourself?
 
  On Tue, Jan 13, 2009 at 10:32 PM, Rick Faircloth wrote:
 
   This is a completely different part of the problem.
   The other parts have been solved, but I couldn't make sense
   of the success part.
 
   If you don't want to help, don't respond.
 
   And if you really are concerned about the number of posts,
   contribute to making them unnecessary by helping with the problem.
 
   You took up more ink on the page by complaining about the
   posts than you would if you had just answered the question.
 
   I'll just assume you don't know...so please keep the responses
   off my thread unless you want to be helpful.
 
   Rick




[jQuery] Re: @name deprecated?

2009-01-13 Thread Karl Rudd

Guys, it's probably a good time for a time out. This is doing no one
any good, least of all those reading the list.

(See my post in the other thread.)

Karl Rudd

On Wed, Jan 14, 2009 at 4:15 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 Well, I'm sure John will run all his documentation by you to make
 sure it's up to your standards.

 And while I may not be able to offer you any specific knowledge
 concerning jQuery, since you obviously know everything and never
 have any questions that you can't find answers to, I most certainly
 can comment on your approach to understanding new releases.

 You see to have to same lack of commitment to finding information
 for yourself that you accuse me of.



 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of MorningZ
 Sent: Wednesday, January 14, 2009 12:10 AM
 To: jQuery (English)
 Subject: [jQuery] Re: @name deprecated?


 Rick... you are the last person in the world who should give me, or
 anyone else for that matter, ANY jQuery-related advice

 And i personally was/am disappointed by the lack of documentation for
 my purposes  i wasn't saying everyone felt this way, just me
 and if that doesn't matter much... oh f__cking well...  i'll continue
 using 1.2.6, which i'm perfectly content with


 On Jan 14, 12:02 am, Rick Faircloth r...@whitestonemedia.com
 wrote:
  MorningZ...
 
  It would be appreciated if you would bother to read the change logs
  before asking questions or making any commentary.  Obviously, as John
  suggested, you haven't bothered to read what has been offered, so what
  you have likely done if a more comprehensive change log had been
  created...you would have had more opportunity to understand the situation
  that you could ignore.
 
  And concerning new releases, it's not John's responsibility to make sure
  you understand all the code that might be affected.  Any professional
  developer would set up a test bed to run the new releases through and
  check for problems in advance.
 
   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
   Behalf Of MorningZ
   Sent: Tuesday, January 13, 2009 11:44 PM
   To: jQuery (English)
   Subject: [jQuery] Re: @name deprecated?
 
   So 5 things changed in this release?
 
   I was hoping for a more comprehensive change log.  i've wanted to
   see sizzle in action on a very busy site i have jQuery running on,
   but the bottom line is i was/still-am scared to death to make the
   change from 1.2.6 to 1.3 because i have no idea what has changed to
   look out for (for instance, Jorn's validation plugin no longer working
   as someone posted).
 
   It's all good though, i'm just one person..  if you've got plenty
   of feedback from posting about 5 changes, then more power to ya
 
   On Jan 13, 11:34 pm, John Resig jere...@gmail.com wrote:
 Why disappointingly?
 
 Because 1.2 to 1.3 is a big major release... and there's a few post 
 to
 test test test, but there's no indication of what to test for..
 what's changed  what could break
 
Huh? Did you miss the beta 1 post where we outlined everything that
could've 
broken?http://blog.jquery.com/2008/12/22/help-test-jquery-13-beta-1/
 
I think we outlined it there fairly well - and we've gotten some great 
feedback.
 
--John




[jQuery] Re: In this code, what would $(this) in the success part refer to?

2009-01-13 Thread Karl Rudd

Perhaps it might be beneficial for you to get a few good books on
JavaScript and learn more that way. It may be an easier route for you
than having to ask the list some of the simpler questions.

Unfortunately I can't actually personally recommend you any books,
when I started JavaScript they were few and far between. Perhaps a few
others might be able to chime in with some suggestions. Perhaps an OT
post asking for JavaScript book recommendations?

I did do a quick search and found these two by eminent JavaScript
programmers, perhaps they might be of assistance:

JavaScript: The Good Parts
http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742

Pro JavaScript Techniques
http://jspro.org/

Karl Rudd

PS It's probably a good time to stop this thread as it's well beyond
it's beginning topic.

On Wed, Jan 14, 2009 at 4:30 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 It's JS that I know little about.  My sites are CSS based in their layouts.
 I have no problem with the CSS, it's just the syntax and some of the
 basic operation of JS that takes a while to understand.

 And keep in mind, that even quantum physicist had to learn about
 gravity before he could understand quantum physics.

 I do appreciate your help and, especially the links.

 Rick


 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Karl Rudd
 Sent: Wednesday, January 14, 2009 12:16 AM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: In this code, what would $(this) in the success part 
 refer to?


 Guys, it's probably a good time for a time out. This is doing no one
 any good, least of all those reading the list.

 I understand MorningZ and Matt Quackenbush's frustration, I often feel
 the same way about a lot of the posts on the list, Rick's included. No
 offence intended Rick. I can see that you're trying to do a lot and
 are not familiar with JavaScript/CSS, that does lead to a lot of
 questions.

 Occasionally if the question is read the documentation I'll provide
 a link, but more often than not I just ignore them. It leads to a lot
 less stress, mostly for me :). Trying to explain quantum physics to
 someone who's just learning about gravity is usually a recipe for
 stress for all involved.

 Karl Rudd

 On Wed, Jan 14, 2009 at 3:56 PM, Rick Faircloth
 r...@whitestonemedia.com wrote:
 
  I help myself, too, but often times, answers that are offered
  to problems aren't correct, so you'll certainly hear that didn't work
  if you post an incorrect answer to a question.
 
 
 
  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of MorningZ
  Sent: Tuesday, January 13, 2009 11:38 PM
  To: jQuery (English)
  Subject: [jQuery] Re: In this code, what would $(this) in the success 
  part refer to?
 
 
  that's exactly the point i was reaching at
 
  some people, myself included, point out a syntax error in the posted
  code... only to have it changed to as suggested and then a new post of
  that didn't work!...  there's no effort shown to understanding why  $
  (this) and $(this) are two totally different things...  just that
  it didn't work
 
  the whole underlying problem is a total lack of understanding of
  selectors and what they are getting
 
  whatever though... i know i am not alone in opening a new topic only
  to see it the same exact post from before  it's just that i'm the
  first person to speak of it  so don't burn me at the stake for
  saying what many others are thinking.   as Matt says, you have to
  help yourself first
 
 
 
  On Jan 13, 11:33 pm, Matt Quackenbush quackfu...@gmail.com wrote:
   Has it ever occurred to you that maybe, just maybe, people are sick and
   tired of helping you when you refuse to help yourself?
  
   On Tue, Jan 13, 2009 at 10:32 PM, Rick Faircloth wrote:
  
This is a completely different part of the problem.
The other parts have been solved, but I couldn't make sense
of the success part.
  
If you don't want to help, don't respond.
  
And if you really are concerned about the number of posts,
contribute to making them unnecessary by helping with the problem.
  
You took up more ink on the page by complaining about the
posts than you would if you had just answered the question.
  
I'll just assume you don't know...so please keep the responses
off my thread unless you want to be helpful.
  
Rick
 
 




[jQuery] Re: Select all controls of the form

2009-01-12 Thread Karl Rudd

The '*' selector will select _all_ the nodes (including the br/s).
Try using the ':input' selector:

$(#form1 :input)

http://docs.jquery.com/Selectors

Karl Rudd

On Tue, Jan 13, 2009 at 5:16 PM, JQueryProgrammer
jain.ashis...@gmail.com wrote:

 I am trying to validate all the controls that exist in the form. My
 form code looks like:

 form id=form1
input type=text id=txt1 name=txt1 /
br/
textarea name=txtArea id=txtArea cols=100 rows=4 /
br/
select id=sel1 name=sel1 style=width: 250px; 
option value=Select/option
option value=1One/option
option value=2Two/option
option value=3Three/option
/select
br/
input type=radio id=rdo1 name=rdo1
 value=Option1nbsp;Option 1nbsp;
br/
input type=radio id=rdo2 name=rdo1
 value=Option2nbsp;Option 2nbsp;
br/
button id=btn1Submit/button
button id=btn2Reset/button
 /form

 I want to select only the controls of the form viz: textbox, textarea,
 select, radio  button (Total 7). I am trying to extract them as

 $(#form1 *).each(function() {
 alert($(#+this).attr(id));
 })

 it gives me total 16 alerts. I want just 7. Any help..?


[jQuery] Re: Select all controls of the form

2009-01-12 Thread Karl Rudd

Errr img elements aren't form controls. input type=image
elements are but :input selects those. I'm not sure what you mean.

Karl Rudd

On Tue, Jan 13, 2009 at 5:43 PM, JQueryProgrammer
jain.ashis...@gmail.com wrote:

 The above code selects all the controls except img tag.



 On Jan 13, 11:26 am, Karl Rudd karl.r...@gmail.com wrote:
 The '*' selector will select _all_ the nodes (including the br/s).
 Try using the ':input' selector:

 $(#form1 :input)

 http://docs.jquery.com/Selectors

 Karl Rudd

 On Tue, Jan 13, 2009 at 5:16 PM, JQueryProgrammer

 jain.ashis...@gmail.com wrote:

  I am trying to validate all the controls that exist in the form. My
  form code looks like:

  form id=form1
 input type=text id=txt1 name=txt1 /
 br/
 textarea name=txtArea id=txtArea cols=100 rows=4 /
 br/
 select id=sel1 name=sel1 style=width: 250px; 
 option value=Select/option
 option value=1One/option
 option value=2Two/option
 option value=3Three/option
 /select
 br/
 input type=radio id=rdo1 name=rdo1
  value=Option1nbsp;Option 1nbsp;
 br/
 input type=radio id=rdo2 name=rdo1
  value=Option2nbsp;Option 2nbsp;
 br/
 button id=btn1Submit/button
 button id=btn2Reset/button
  /form

  I want to select only the controls of the form viz: textbox, textarea,
  select, radio  button (Total 7). I am trying to extract them as

  $(#form1 *).each(function() {
  alert($(#+this).attr(id));
  })

  it gives me total 16 alerts. I want just 7. Any help..?


[jQuery] Re: i can't modify the header with beforeSend

2009-01-11 Thread Karl Rudd

The cross domain JSONP type request doesn't use the XMLHttpRequest
object/system. Indeed it couldn't because XMLHttpRequest can't be done
across domains (at least not yet, standards are being formulated).

What happens is that a script tag with the requested URL is inserted
in the document, so no headers can be set.

You'll have to use a proxy on a local server, ie:

http://developer.yahoo.com/javascript/howto-proxy.html

Karl Rudd

On Mon, Jan 12, 2009 at 2:20 AM, ximiff xim...@gmail.com wrote:

 I'm trying to auto login to twitter api with adding a Authorization
 header. When i run my code below , i found that the request headers
 still not modified with firebug, and the browser pop a window to input
 username and password. How can I handle that?

 code

 var url = http://twitter.com/account/verify_credentials.json?
 callback=?;

$.ajax({
  beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader(Authorization, Basic
 eWlzdWRvbmdAZ21haWwuY29tOmV2YTBldwEs);
  },
  type: GET,
  url: url,
  dataType: jsonp,
  success: function(data){
alert( Data Saved:  + data[friends_count] );
   }
});


 /code



[jQuery] Re: append() not working on dynamically-created nodes in IE

2009-01-11 Thread Karl Rudd

Try closing the tag, ie:

$('#myDiv').append($('h2/h2'));

Actually the second $() shouldn't be needed:

$('#myDiv').append('h2/h2');

Karl Rudd

On Mon, Jan 12, 2009 at 7:35 AM, Joe White vulcanvik...@gmail.com wrote:

 I'm troubleshooting a problem where my text wasn't showing up in IE.
 I've narrowed the problem down to creating a DOM node dynamically
 (with $(html)) and then passing it to append(). In FireFox, append
 will add the node as expected; but when passed a dynamically-created
 node in IE, it does nothing. No error message is displayed; it just
 silently fails, and no node is added to the page.

 Here's a trivial example:

 $('#myDiv').append($('h2'));

 I put that code into the ready event, on a page with a div id=myDiv.
 I also added some CSS to put a border on the h2, so I'd be able to see
 whether it got added. Result: in FireFox, I can see the border,
 proving that the h2 got added. In IE, nothing. No error.

 If, instead, I find an existing h2 using its selector (e.g. $
 ('#myH2')), and append() that (instead of a dynamically-created one),
 then IE works fine; it moves that existing element into myDiv. It
 appears to just be when a DOM element is dynamically created with $
 (html), and then append()ed, that there's a problem.

 Full example:

 html
 head
 styleh2{border:1px solid blue;}/style
 script src=../vendor/jquery/jquery-1.2.6.js/script
 script
 $(function(){
  $('#myDiv').append($('h2'));
 });
 /script
 /head
 body
 div id=myDiv/div
 /body
 /html

 Expected behavior: when you run this, you should get a blank page with
 a 2px-tall blue line extending across the page. (This is the border
 around the h2.) FireFox shows this expected behavior.

 Actual behavior (IE6 on Windows): you get a blank page. The status bar
 just says Done like usual, and does not show that any errors
 occurred.

 Is this a bug in jQuery? Or am I misunderstanding how $(html) is meant
 to be used?



[jQuery] Re: - Enable then Disable buttons

2009-01-03 Thread Karl Rudd

Untested but this should do the trick.

$('#theSelectorForTheButton').click( function() {
  var button = this;
  button.disabled = true;
  setTimeout( function() { button.disabled = false; }, 3000 };
});

Karl Rudd

On Sun, Jan 4, 2009 at 2:22 PM, Commandos chaab...@gmail.com wrote:

 How can i disable a button for 3 seconds  then after that enable it
 when a use click a  button (to avoid the user clicking without
 stopping)


 Button Enabled - user click the button - button is disabled for 3
 seconds - button is enabled .


[jQuery] Re: - Enable then Disable buttons

2009-01-03 Thread Karl Rudd

Woops. Mistyped the second to last bracket. Should be a '(', rather than '{';

$('#theSelectorForTheButton').click( function() {
 var button = this;
 button.disabled = true;
 setTimeout( function() { button.disabled = false; }, 3000 );
});

On Sun, Jan 4, 2009 at 5:15 PM, Karl Rudd karl.r...@gmail.com wrote:
 Untested but this should do the trick.

 $('#theSelectorForTheButton').click( function() {
  var button = this;
  button.disabled = true;
  setTimeout( function() { button.disabled = false; }, 3000 };
 });

 Karl Rudd

 On Sun, Jan 4, 2009 at 2:22 PM, Commandos chaab...@gmail.com wrote:

 How can i disable a button for 3 seconds  then after that enable it
 when a use click a  button (to avoid the user clicking without
 stopping)


 Button Enabled - user click the button - button is disabled for 3
 seconds - button is enabled .



[jQuery] Re: Posting multiple values from a checkbox

2008-12-30 Thread Karl Rudd

Correct, the syntax is wrong. You want:

input type=checkbox name=food1 value=apples'Apples
input type=checkbox name=food2 value=Pizza'Pizza
input type=checkbox name=food3 value=Cake'Cake

Inputs are keyed on their name not their id.

Karl Rudd

On Wed, Dec 31, 2008 at 7:53 AM, tradeallday jonathanpat...@gmail.com wrote:

 I've got checkboxes on my page. When I use the $.post method, it's
 only transmitting the first value out of my list. Here's my code:

 $.post(http://localhost/search_engine.php,{
food_type: $(#food_type).val(),
foods: $(:checkbox).fieldValue(),
   }, function(xml) {
   displayResult(xml);
 });

 the checkboxes look like this:

 input type=checkbox id=foods value=apples'Apples
 input type=checkbox id=foods value=Pizza'Pizza
 input type=checkbox id=foods value=Cake'Cake

 If I check all three, I only get the first one, although if I do an
 alert of

 $(:checkbox).fieldValue()

 I get back all the results I selected.

 I'm using the jquery form library jquery.form.js.

 Should I be posting this data some other way? Or is my syntax wrong?

 Thanks,



[jQuery] Re: applying css style to past dates

2008-12-28 Thread Karl Rudd

I suggest adding a class rather than specifically changing the style.
It keeps the presentation (CSS/styling) nicely separate from the
JavaScript and makes both much easier to deal with.

So the JavaScript would be something like (note I changed round the
selector to :text.date, more efficient this way):

   $(document).ready(function(){
   $(:text.date).each(function (i) {
   if(parse(this.value)  Date.getTime()) {
   $(this).addClass(pastDate);
   }
   });
   })

And in the CSS:

.pastDate {
color: red;
}

Karl Rudd

On Mon, Dec 29, 2008 at 11:52 AM, Matt matt.neil...@gmail.com wrote:

 Hi,

 I'm trying to make text red when a date in an input field occurs in
 the past. However, it isn't working when I try it out.. I'm new to
 JQuery, so i'm not sure what i'm doing wrong..

$(document).ready(function(){
$(.date:text).each(function (i) {
if(parse(this.value)  Date.getTime()) {
this.style.color = red;
}
});
});

 This is one of the input fields that I want it to turn red.

 input class=date type=text value=11/17/2008 name=expires_256/


 Any ideas? I'd love the help. :)

 Thanks in advance,

 Matt


[jQuery] Re: getJSON invalid label

2008-12-25 Thread Karl Rudd

That's probably the cache buster parameter (added mostly for
Internet Explorer's benefit).

Use the $.ajax( { /* options */ } ); function (
http://docs.jquery.com/Ajax/jQuery.ajax#options ) and add cache: false
to the options. Like so:

$(form).submit(function() {
  $.ajax({
dataType: jsonp,
url: http://someplace.com?someparam=123callback=?;,
query: $(#query).val(),
cache: false,
success: function(data){ alert(data); }
  });
  return false;
});

Karl Rudd

On Fri, Dec 26, 2008 at 5:29 AM, mark markj...@gmail.com wrote:

 jrutter,

 I am having a similar issue with the Yahoo music api. In my case
 jQuery is replacing the url:
   
 http://us.music.yahooapis.com/artist/v1/list/published/popular?response=mainappid=myappidformat=jsoncallback=?
 with

 http://us.music.yahooapis.com/artist/v1/list/published/popular?response=mainappid=myappidformat=jsoncallback=jsonp1230228631768_=1230228631798

 As you can see jquery replaced the last ? with jsonp1230228631768
 (ok), but it also adds _=1230228631798 (not ok) to the end. This last
 part is what Yahoo is flagging as a bad parameter. Some services, such
 as Flickr, simply ignore that last parameter.
 You may want to check if that is the same issue you are having, but
 unfortunately I don't know how to fix it...

 On Dec 11, 9:28 am, jrutter jake.rut...@gmail.com wrote:
 What am I doing wrong? Im able to submit the request and get a
 response, but in Firebug it says invalid label and the alert doesnt
 show up.

 here is my code:

   $(form).submit(function() {

   $.getJSON(http://api.nytimes.com/svc/movies/v2/reviews/
 search.json?api-
 key=c82338627fba39e9bcb953728fe445a2:15:57546791callback=?, {query :
 $('#query').val()}, function(data){
   alert(data);

   });

  return false;

});



[jQuery] Re: Ajax.Form() fire onchange of elements

2008-12-25 Thread Karl Rudd

Errr I've not heard of AjaxForm(), there's an ajaxForm() method in
Mike's Form plugin ( http://plugins.jquery.com/project/form ).

If the Form plugin is the one you're referring too then you could
bind a function that calls the ajaxSubmit() function to the change
event of a form element. For example (untested):

$('#myFormId')
.submit(function() {
$(this).ajaxSubmit();
return false;
})
.find(':input').change(function() {
$(this).ajaxSubmit();
});

Karl Rudd

On Thu, Dec 25, 2008 at 10:00 PM, ERP Evaluierungs leitfaden
phil...@workx.at wrote:

 Hi

 I started with jQuery 3 days ago, was using Prototype before.

 My problem right now is AjaxForm()

 It works perfect but just if the user clicks submit.

 Is it also possible to fire the form to the server if one
 of the Values changes??

 For example:
 I'm working on something like a shopping basket where the user
 can change the amount and delete products.

 All actions cause the final Price-Sum which should be calculated in
 realtime. Meaning, the user might change the amount of a product and
 jQuery (Ajax.Form) should submit it and get the new price sum back.

 For the price-calculation I need all the time all values in my PHP
 script.

 THX  a lot!

 Cheers Philipp



[jQuery] Re: jQuery and $.post with PHP and $_POST

2008-12-24 Thread Karl Rudd

Unless a submit button is explicitly pressed it's value won't be sent.
So in the case given, since there are no other form elements, nothing
with be posted to the server.

Karl Rudd

On Wed, Dec 24, 2008 at 11:36 PM, Brett Alton brett.jr.al...@gmail.com wrote:

 How do I get PHP to print JavaScript variables via $_POST? jQuery's
 $.post doesn't seem to be submitting any data.

 This is a sample of what I have...

 test.php:
 --
 ?php
echo 'pre';
print_r($_POST);
echo '/pre';
 ?
 form method=post action=test.php id=test
input id=submit name=submit type=submit value=Submit
 /form
 --

 jquery.js:
 --
 $(document).ready(function()
 {
$(form#test).bind('submit',(function(){
$.post(test.php,{
// no matter what I put in here, nothing shows up in 
 test.php
});
});
 });
 --

 I've also tried:

 $(form#test).submit(function(){

 instead of bind...


[jQuery] Re: jQuery and $.post with PHP and $_POST

2008-12-24 Thread Karl Rudd

Sorry I misread your first post.

No matter what you put in the form nothing will be sent because $.post
doesn't send a form. You have to explicitly supply it with a JSON
type array/object of values to send.

You may want to check out the Form plugin:

http://www.malsup.com/jquery/form/

If you prefer DIY then take a look at:

http://docs.jquery.com/Ajax/serializeArray

There are also a number of tutorials out there, such as:

http://trevordavis.net/blog/tutorial/ajax-forms-with-jquery/
http://www.sitepoint.com/article/ajax-jquery/3/

Karl Rudd

On Wed, Dec 24, 2008 at 11:54 PM, Brett Alton brett.jr.al...@gmail.com wrote:

 Isn't that what $.post is for though?

 $(form#test).bind('submit',(function(){
$.post(editcustommenu-new.php,{
menu_bg_colour_selector: $('#menu_bg_colour_selector').val()
});*/
alert('form submitted');
  });

 Isn't that supposed to pass 'menu_bg_colour_selector' to $_POST? Or am
 I mixing something up...

 My alert seems to work, but the $.post function doesn't seem to pass
 anything to my PHP code.

 On Dec 24, 7:40 am, Karl Rudd karl.r...@gmail.com wrote:
 Unless a submit button is explicitly pressed it's value won't be sent.
 So in the case given, since there are no other form elements, nothing
 with be posted to the server.

 Karl Rudd

 On Wed, Dec 24, 2008 at 11:36 PM, Brett Alton brett.jr.al...@gmail.com 
 wrote:

  How do I get PHP to print JavaScript variables via $_POST? jQuery's
  $.post doesn't seem to be submitting any data.

  This is a sample of what I have...

  test.php:
  --
  ?php
 echo 'pre';
 print_r($_POST);
 echo '/pre';
  ?
  form method=post action=test.php id=test
 input id=submit name=submit type=submit value=Submit
  /form
  --

  jquery.js:
  --
  $(document).ready(function()
  {
 $(form#test).bind('submit',(function(){
 $.post(test.php,{
 // no matter what I put in here, nothing shows up 
  in test.php
 });
 });
  });
  --

  I've also tried:

  $(form#test).submit(function(){

  instead of bind...


[jQuery] Re: jQuery and $.post with PHP and $_POST

2008-12-24 Thread Karl Rudd

Sorry, typing too fast, reading too little.

Two things are needed:

* $.post needs a callback function so you can get at what is returned.

* the submit handler needs a return false; so the browser won't
continue with the normal submit process.

Karl Rudd

On Wed, Dec 24, 2008 at 11:54 PM, Brett Alton brett.jr.al...@gmail.com wrote:

 Isn't that what $.post is for though?

 $(form#test).bind('submit',(function(){
$.post(editcustommenu-new.php,{
menu_bg_colour_selector: $('#menu_bg_colour_selector').val()
});*/
alert('form submitted');
  });

 Isn't that supposed to pass 'menu_bg_colour_selector' to $_POST? Or am
 I mixing something up...

 My alert seems to work, but the $.post function doesn't seem to pass
 anything to my PHP code.

 On Dec 24, 7:40 am, Karl Rudd karl.r...@gmail.com wrote:
 Unless a submit button is explicitly pressed it's value won't be sent.
 So in the case given, since there are no other form elements, nothing
 with be posted to the server.

 Karl Rudd

 On Wed, Dec 24, 2008 at 11:36 PM, Brett Alton brett.jr.al...@gmail.com 
 wrote:

  How do I get PHP to print JavaScript variables via $_POST? jQuery's
  $.post doesn't seem to be submitting any data.

  This is a sample of what I have...

  test.php:
  --
  ?php
 echo 'pre';
 print_r($_POST);
 echo '/pre';
  ?
  form method=post action=test.php id=test
 input id=submit name=submit type=submit value=Submit
  /form
  --

  jquery.js:
  --
  $(document).ready(function()
  {
 $(form#test).bind('submit',(function(){
 $.post(test.php,{
 // no matter what I put in here, nothing shows up 
  in test.php
 });
 });
  });
  --

  I've also tried:

  $(form#test).submit(function(){

  instead of bind...


[jQuery] Re: How can I generalize this code for all values?

2008-12-22 Thread Karl Rudd

From http://docs.jquery.com/Selectors (Forms section):

:input
Matches all input, textarea, select and button elements.

To select all Form elements with a required class:

$(':input.required')

Karl Rudd


On Tue, Dec 23, 2008 at 2:39 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 How can this:

// all the required text fields
var $required = $('input.required:text');

 be expanded to include 'input.required:select'  ?

 I tried all the variations I could think of, including:

 $('input.required:text', 'input.required:select')

 but that, and every other variation, throws an error.

 What's the syntax for specifying various types of required inputs?

 Rick



 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Kean
 Sent: Monday, December 22, 2008 8:26 PM
 To: jQuery (English)
 Subject: [jQuery] Re: How can I generalize this code for all values?


 try this, it accounts for checking all the required fields to see if
 they are blank and disable

 jQuery(function(){

   // all the required text fields
   var $required = $('input.required:text');

   // function checks for blank input
   var isBlank = function(str) {
   return $.trim(str).length==0
   }

   // function checks if other required fields are blank
   var checkAllRequired = function () {
   var allFilled = true;
   $required.each(function() {
   if (isBlank(this.value))
   allFilled = false;
   });
   return allFilled;
   }

   // initially disable or enable the submit button
   $(#submit).attr('disabled', checkAllRequired() ? null :
 disabled);


   // same as $required each blur
   $required.blur(function() {
   // checks if current field is blank
   if (isBlank(this.value))
   $(# + this.id + _error).fadeIn(500);
   else
   $(# + this.id + _error).fadeOut(500);

   $(#submit).attr('disabled', checkAllRequired() ? null :
 disabled);

  });

 });

 On Dec 22, 3:54 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  Ok...after a lot of experimentation, I've got a solution
  that's working to the point that I've attempted to implement it.
 
  Here's the code:
 
  $(document).ready(function() {
 
   $('input:text.required').each(function() {
$(this).blur(function() {
 var val = (this.value.length);
  if (val == 0)
   { $(# + this.id + _error).fadeIn(500);
 $('#submit').attr('disabled', 'disabled'); }
  else
   { $(# + this.id + _error).fadeOut(500);
 $('#submit').removeAttr('disabled'); };
 
   $('input:text.required').each(function() {
var val = (this.value.length);
 if (val == 0)
  { $('#submit').attr('disabled', 'disabled'); }
   });
 
});
   });
 
  });
 
  This code allows for the following:
 
  - on blur of any text input with class 'required' the length is checked
  - if the length of the required field is  0, then the error message is 
  shown
and the submit button for the form is disabled
 
  - the second half of the code checks all the text inputs with class 
  'required'
  - if the length of any of the required text fields is 0, then the submit 
  button is disabled
 
  What I need to do now:
 
  - Allow for other type of inputs to be checked on blur, etc., such as 
  selects
(Later, I'll add other types of validation, such as numeric, etc.)
 
  Question:
 
  - How do I modify ('input:text.required') to accommodate other types of 
  required inputs?
  - I tried ('input:text.required, input:select.required') and
('input:text.required', 'input:select.required') but that didn't 
  work
 
  Clues or hints?
 
  Thanks,
 
  Rick
 
   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
   Behalf Of MorningZ
   Sent: Monday, December 22, 2008 2:40 PM
   To: jQuery (English)
   Subject: [jQuery] Re: How can I generalize this code for all values?
 
   Try this change
 
   $(#submit).attr('disabled', (val == ) ? disabled : null);
 
   If that doesn't work, then perhaps:
 
   if (val == ) {
 $(# + this.id + _error).fadeIn(500);
 $(#submit).attr(disabled, disabled);
   }
   else {
 $(# + this.id + _error).fadeOut(500);
 $(#submit).removeAttr(disabled);
   }
 
   On Dec 22, 2:21 pm, Rick Faircloth r...@whitestonemedia.com wrote:
I see in your example code that you're still using a hard-coded name
for the input.  I'd like it completely generalized for all variables.
 
I'm working towards creating code for categories of input types:  text,
radio, checkbox

[jQuery] Re: How can I generalize this code for all values?

2008-12-22 Thread Karl Rudd

Not quite sure what you're asking. Why would you try to set the
select's value? The select gets it's value from the selected child
option.

My advice would be to use the Jorn's plugin (
http://docs.jquery.com/Plugins/Validation ). From what I can see it
seems to do validation on blur by default.

Karl Rudd

On Tue, Dec 23, 2008 at 2:54 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 D'oh!  I can't believe it was that simple!
 And I read everything I could find, including the docs on selectors.
 (Should have read it twice, I guess...)

 Anyway, question, Karl, et al...

 How can I validate a select input?

 I've tried setting the default select value to 
 which I thought would be equivalent to value.length == 0,
 but nothing's happening with the error message.
 Others are working fine.

 Suggestions?

 Thanks,

 Rick



 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Karl Rudd
 Sent: Monday, December 22, 2008 10:43 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: How can I generalize this code for all values?


 From http://docs.jquery.com/Selectors (Forms section):

 :input
 Matches all input, textarea, select and button elements.

 To select all Form elements with a required class:

 $(':input.required')

 Karl Rudd


 On Tue, Dec 23, 2008 at 2:39 PM, Rick Faircloth
 r...@whitestonemedia.com wrote:
 
  How can this:
 
 // all the required text fields
 var $required = $('input.required:text');
 
  be expanded to include 'input.required:select'  ?
 
  I tried all the variations I could think of, including:
 
  $('input.required:text', 'input.required:select')
 
  but that, and every other variation, throws an error.
 
  What's the syntax for specifying various types of required inputs?
 
  Rick
 
 
 
  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Kean
  Sent: Monday, December 22, 2008 8:26 PM
  To: jQuery (English)
  Subject: [jQuery] Re: How can I generalize this code for all values?
 
 
  try this, it accounts for checking all the required fields to see if
  they are blank and disable
 
  jQuery(function(){
 
// all the required text fields
var $required = $('input.required:text');
 
// function checks for blank input
var isBlank = function(str) {
return $.trim(str).length==0
}
 
// function checks if other required fields are blank
var checkAllRequired = function () {
var allFilled = true;
$required.each(function() {
if (isBlank(this.value))
allFilled = false;
});
return allFilled;
}
 
// initially disable or enable the submit button
$(#submit).attr('disabled', checkAllRequired() ? null :
  disabled);
 
 
// same as $required each blur
$required.blur(function() {
// checks if current field is blank
if (isBlank(this.value))
$(# + this.id + _error).fadeIn(500);
else
$(# + this.id + _error).fadeOut(500);
 
$(#submit).attr('disabled', checkAllRequired() ? null :
  disabled);
 
   });
 
  });
 
  On Dec 22, 3:54 pm, Rick Faircloth r...@whitestonemedia.com wrote:
   Ok...after a lot of experimentation, I've got a solution
   that's working to the point that I've attempted to implement it.
  
   Here's the code:
  
   $(document).ready(function() {
  
$('input:text.required').each(function() {
 $(this).blur(function() {
  var val = (this.value.length);
   if (val == 0)
{ $(# + this.id + _error).fadeIn(500);
  $('#submit').attr('disabled', 'disabled'); }
   else
{ $(# + this.id + _error).fadeOut(500);
  $('#submit').removeAttr('disabled'); };
  
$('input:text.required').each(function() {
 var val = (this.value.length);
  if (val == 0)
   { $('#submit').attr('disabled', 'disabled'); }
});
  
 });
});
  
   });
  
   This code allows for the following:
  
   - on blur of any text input with class 'required' the length is checked
   - if the length of the required field is  0, then the error message is 
   shown
 and the submit button for the form is disabled
  
   - the second half of the code checks all the text inputs with class 
   'required'
   - if the length of any of the required text fields is 0, then the 
   submit button is disabled
  
   What I need to do now:
  
   - Allow for other type of inputs to be checked on blur, etc., such as 
   selects
 (Later, I'll add other types of validation, such as numeric, etc

[jQuery] Re: How can I generalize this code for all values?

2008-12-22 Thread Karl Rudd

Have a look at the validate method (
http://docs.jquery.com/Plugins/Validation/validate )

According to the documentation to suppress validation on submission
all you need to do is:

$('form').validate({
   onsubmit: false
});

Note: I've never used the plugin before, so this is all untested.

Karl Rudd

On Tue, Dec 23, 2008 at 3:45 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 The select gets it's value from the selected child option.

 Perhaps that's why I can't get validation to work!

 My advice would be to use the Jorn's plugin

 Believe me, I've tried.

 I worked with it every way I could think of to disable
 the default onSubmit event and cause validation only
 onblur, but I couldn't make it work.

 I haven't heard anything from Jorn, but if you or anyone
 knows how to make the validation occur only onblur, please
 let me know.

 I don't need or want onSubmit at all...I have server-side
 validation that will take care of it once it's submitted.

 Rick


 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Karl Rudd
 Sent: Monday, December 22, 2008 11:37 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: How can I generalize this code for all values?


 Not quite sure what you're asking. Why would you try to set the
 select's value? The select gets it's value from the selected child
 option.

 My advice would be to use the Jorn's plugin (
 http://docs.jquery.com/Plugins/Validation ). From what I can see it
 seems to do validation on blur by default.

 Karl Rudd

 On Tue, Dec 23, 2008 at 2:54 PM, Rick Faircloth
 r...@whitestonemedia.com wrote:
 
  D'oh!  I can't believe it was that simple!
  And I read everything I could find, including the docs on selectors.
  (Should have read it twice, I guess...)
 
  Anyway, question, Karl, et al...
 
  How can I validate a select input?
 
  I've tried setting the default select value to 
  which I thought would be equivalent to value.length == 0,
  but nothing's happening with the error message.
  Others are working fine.
 
  Suggestions?
 
  Thanks,
 
  Rick
 
 
 
  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Karl Rudd
  Sent: Monday, December 22, 2008 10:43 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: How can I generalize this code for all values?
 
 
  From http://docs.jquery.com/Selectors (Forms section):
 
  :input
  Matches all input, textarea, select and button elements.
 
  To select all Form elements with a required class:
 
  $(':input.required')
 
  Karl Rudd
 
 
  On Tue, Dec 23, 2008 at 2:39 PM, Rick Faircloth
  r...@whitestonemedia.com wrote:
  
   How can this:
  
  // all the required text fields
  var $required = $('input.required:text');
  
   be expanded to include 'input.required:select'  ?
  
   I tried all the variations I could think of, including:
  
   $('input.required:text', 'input.required:select')
  
   but that, and every other variation, throws an error.
  
   What's the syntax for specifying various types of required inputs?
  
   Rick
  
  
  
   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] 
   On Behalf Of Kean
   Sent: Monday, December 22, 2008 8:26 PM
   To: jQuery (English)
   Subject: [jQuery] Re: How can I generalize this code for all values?
  
  
   try this, it accounts for checking all the required fields to see if
   they are blank and disable
  
   jQuery(function(){
  
 // all the required text fields
 var $required = $('input.required:text');
  
 // function checks for blank input
 var isBlank = function(str) {
 return $.trim(str).length==0
 }
  
 // function checks if other required fields are blank
 var checkAllRequired = function () {
 var allFilled = true;
 $required.each(function() {
 if (isBlank(this.value))
 allFilled = false;
 });
 return allFilled;
 }
  
 // initially disable or enable the submit button
 $(#submit).attr('disabled', checkAllRequired() ? null :
   disabled);
  
  
 // same as $required each blur
 $required.blur(function() {
 // checks if current field is blank
 if (isBlank(this.value))
 $(# + this.id + _error).fadeIn(500);
 else
 $(# + this.id + _error).fadeOut(500);
  
 $(#submit).attr('disabled', checkAllRequired() ? null :
   disabled);
  
});
  
   });
  
   On Dec 22, 3:54 pm, Rick Faircloth r...@whitestonemedia.com wrote:
Ok...after a lot of experimentation, I've got a solution
that's working to the point that I've attempted to implement it.
   
Here's the code:
   
$(document).ready(function

[jQuery] Re: eq() driving me nuts...

2008-12-15 Thread Karl Rudd

There shouldn't be 2 elements with the same id. Try using a class.

There are no a elements inside the divs. I presume this is just a
cut and paste error?

Karl Rudd

On Tue, Dec 16, 2008 at 9:24 AM, asrij...@googlemail.com
asrij...@googlemail.com wrote:

 Hi Guys,

 gotta problem here and i don't know why it occurs:

 Example:
 Simple Html Page
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 html
  head
  meta http-equiv=content-type content=text/html;
 charset=windows-1250
  meta name=generator content=PSPad editor, www.pspad.com
  title/title
  script type=text/javascript src=js/jquery.js/script
  /head
  body

script type=text/javascript
jQuery.noConflict();
  jQuery(document).ready(function() {
alert( jQuery('#test:eq(1)  a:eq(0)').attr('href') );
  });
/script

div id=test
test
/div
div id=test
test
/div
  /body
 /html

 if '#test:eq(0)  a:eq(0)' is set, it returns the right href value.
 But when I change it to '#test:eq(1)  a:eq(0)' I only get
 undefinied from my alert box.

 Can anyone explain me why? I dont get it, maybe I'm doing a big
 mistake in my little code.

 thx a lot



[jQuery] Re: Where's my syntax error?

2008-12-15 Thread Karl Rudd

Remove the last )

Karl Rudd

On Tue, Dec 16, 2008 at 12:31 PM, Rick Faircloth
r...@whitestonemedia.com wrote:

 Can't figure out what I've got wrong.
 Firebug is telling me syntax error });

 Could someone please point out the error?
 (Perhaps the entire coding is wrong...just trying
 out something similar I saw on the list a moment ago)

 Thanks,

 Rick

 script type=text/javascript

$(document).ready(function(){
$(#emailError).hide();
});

function validateEmail() {

$(input.email).blur(function() {

if (this.val.length == 0)
$(#emailError).show();
});
});

 /script




[jQuery] Re: problem using jquery and prototype together

2008-12-11 Thread Karl Rudd
If you take a look at the last part of
http://docs.jquery.com/Using_jQuery_with_Other_Libraries you'll see a
solution.

Basically wrap your jQuery code in one of these two:

(function($) { /* some code that uses $ */ })(jQuery)
jQuery(function($) { /* some code that uses $. run on document.ready */ });

Karl Rudd

On Fri, Dec 12, 2008 at 6:06 PM, ♫ cheskonov amardeep.sar...@gmail.com wrote:

 This could sound a stupid question but here is my problem :
 is there a way to use $ sign while working with jQuery and Prototype
 together?
 it seems that using both causes a conflict with the $ sign and if i
 use jQuery.noConflict(true); i need to replace all $ sign with
 jQuery . is there a way i can avoid this


[jQuery] Re: Select option value not working

2008-12-09 Thread Karl Rudd

The SELECT's value is what you want:

$(input[name='myselect']).val()

The only time you need to check is individual OPTIONs are selected is
if you have a multi-select list box.

Karl Rudd

On Tue, Dec 9, 2008 at 8:09 PM, JQueryProgrammer
[EMAIL PROTECTED] wrote:

 $(input[name='myselect'] option:selected).val(); is not working. It
 gives undefined. Can anyone please help.


[jQuery] Re: Select option value not working

2008-12-09 Thread Karl Rudd

Heh yeah that too. :) Sorry I missed that detail.

Karl Rudd

On Tue, Dec 9, 2008 at 9:08 PM, Rik Lomas [EMAIL PROTECTED] wrote:

 It could be to do with the select isn't an input tag, it's a select
 tag, try $(select[name='myselect'] option:selected).val(); instead

 Rik


 2008/12/9 Karl Rudd [EMAIL PROTECTED]:

 The SELECT's value is what you want:

$(input[name='myselect']).val()

 The only time you need to check is individual OPTIONs are selected is
 if you have a multi-select list box.

 Karl Rudd

 On Tue, Dec 9, 2008 at 8:09 PM, JQueryProgrammer
 [EMAIL PROTECTED] wrote:

 $(input[name='myselect'] option:selected).val(); is not working. It
 gives undefined. Can anyone please help.




 --
 Rik Lomas
 http://rikrikrik.com



[jQuery] Re: Simultaneous $.load() calls wait for eachother

2008-12-09 Thread Karl Rudd
Unless the ajaxSetup() function is being called with 'async': false,
then load() (and any other ajax based methods) will work
asynchronously.

Karl Rudd

On Wed, Dec 10, 2008 at 12:27 AM, Robin Speekenbrink
[EMAIL PROTECTED] wrote:

 I have a (stupid) problem: i have the follwing short script:
 $(window).load(function() {
$(#div1).load('/xmlHttp.php?action=getLoad');
$(#div2).load(/xmlHttp.php?action=+ $(input
 [name='selectType']).val());
 });

 What this does: it calls the central xmlHttp url to fetch data. Simple
 right? Except that the first call can stall the second? The second
 call will finish only when the first is already done?

 It seems that the second call waits for the first to be done? (ór its
 just a widly strange coincidence that the two calls each take the
 exact amount of time according to firebug)

 the overall settings are as follows:
 $.ajaxSetup({cache: false});

 If i rearrange the first call áfter the second the results are as
 expected: #div2 is filled quickly while div1 is still loading...

 Is this a bug or something else?



[jQuery] Re: Remote requests using $ajax

2008-12-07 Thread Karl Rudd

Try looking at the getJSON method:

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

It's the only way to do direct cross-domain communication from the
client-side. (The other option is you use a proxy on your server and
route requests through there.)

Karl Rudd

On Mon, Dec 8, 2008 at 4:52 PM, dave [EMAIL PROTECTED] wrote:

 Hey all,
 I'm in need of making a remote request (i.e. to a different domain)
 using the $.ajax function.  Doing some preliminary research on google
 and this group, it looks like the most popular workaround is to call a
 separate local script using $ajax; and then having the local script
 perform the actual remote request.  However, for my current situation,
 I cannot utilize a local script.

 The documentation for $ajax seems to imply that jquery supports remote
 calls, unless I'm misinterpreting this line:
 All remote (not on the same domain) POST requests are converted to
 GET when 'script' is the dataType (because it loads script using a DOM
 script tag).
 http://docs.jquery.com/Ajax/jQuery.ajax

 Can someone post an example of a remote request using $ajax?

 Please let me know if you'd me to clarify.  Thanks!

 Dave


[jQuery] Re: addClass with attrs

2008-12-06 Thread Karl Rudd

Try this plugin:

http://plugins.jquery.com/project/Rule

Karl Rudd

On Sun, Dec 7, 2008 at 9:50 AM, Dirceu Barquette
[EMAIL PROTECTED] wrote:
 Hi!

 How can I add a class with its attrs dynamically?

 like this (not works, obvious ...)--- $('#div').addClass('blah
 {background:#000}')

 Thanks,

 Dirceu Barquette



[jQuery] Re: Doing Ajax call to a page that requires authentication

2008-11-29 Thread Karl Rudd

You can get around it by using a JSON (or JSONP) response. For
cross-domain JSON calls a script tag is inserted and the content is
read that way.

Karl Rudd

On Sat, Nov 29, 2008 at 11:17 PM, TheBlueSky [EMAIL PROTECTED] wrote:

 Oh, sorry, my mistake! Yes, it's on another domain and I've just noted
 that.

 By the way, there is no way around this, is there?

 On Nov 27, 3:40 pm, Karl Rudd [EMAIL PROTECTED] wrote:
 Is the page/resource in another domain? That would obviously not work.
 That's the only thing I can think of.

 Karl Rudd



 On Thu, Nov 27, 2008 at 9:20 PM, TheBlueSky [EMAIL PROTECTED] wrote:

  Thanks for your reply.

  Sorry that my question wasn't clear enough; I already tried using the
  username/password options for ajax() method, however, I'm getting
  'Permission denied to call method XMLHttpRequest.open' kind of
  message. I don't know if there is something else need to be done or
  not.

  By the way, the credentials I'm using are correct.

  On Nov 25, 4:24 pm, Pierre Bellan [EMAIL PROTECTED] wrote:
  Hi,
  If the authentification is form-based, then the login credentials is 
  passed
  by GET or POST.
  So you just have to add it to your ajax request

  see the data option.

  $.ajax({
 type: POST,
 url: some.php,
 data: name=Johnlocation=Boston,
 success: function(msg){
   alert( Data Saved:  + msg );
 }
   });

  If the authentification is based on .htaccess, you can use 
  username/password
  option

  Pierre

  W. C. Fields  - I cook with wine, sometimes I even add it to the food.

  2008/11/25 TheBlueSky [EMAIL PROTECTED]

   Hi everyone,
   How can I send login credentials with jQuery Ajax request (get(), post
   () or ajax()) when the page I'm requesting is asking for them before
   permitting the access.
   Note here that I'm not talking here about form-based authentication.
   Thanks in advance.- Hide quoted text -

  - Show quoted text -- Hide quoted text -

 - Show quoted text -


[jQuery] Re: Doing Ajax call to a page that requires authentication

2008-11-29 Thread Karl Rudd

Oh and I because of the fact that a script tag is used the only
arguments that can be passed in are GET type arguments in the actual
URL.

Karl Rudd

On Sun, Nov 30, 2008 at 9:48 AM, Karl Rudd [EMAIL PROTECTED] wrote:
 You can get around it by using a JSON (or JSONP) response. For
 cross-domain JSON calls a script tag is inserted and the content is
 read that way.

 Karl Rudd

 On Sat, Nov 29, 2008 at 11:17 PM, TheBlueSky [EMAIL PROTECTED] wrote:

 Oh, sorry, my mistake! Yes, it's on another domain and I've just noted
 that.

 By the way, there is no way around this, is there?

 On Nov 27, 3:40 pm, Karl Rudd [EMAIL PROTECTED] wrote:
 Is the page/resource in another domain? That would obviously not work.
 That's the only thing I can think of.

 Karl Rudd



 On Thu, Nov 27, 2008 at 9:20 PM, TheBlueSky [EMAIL PROTECTED] wrote:

  Thanks for your reply.

  Sorry that my question wasn't clear enough; I already tried using the
  username/password options for ajax() method, however, I'm getting
  'Permission denied to call method XMLHttpRequest.open' kind of
  message. I don't know if there is something else need to be done or
  not.

  By the way, the credentials I'm using are correct.

  On Nov 25, 4:24 pm, Pierre Bellan [EMAIL PROTECTED] wrote:
  Hi,
  If the authentification is form-based, then the login credentials is 
  passed
  by GET or POST.
  So you just have to add it to your ajax request

  see the data option.

  $.ajax({
 type: POST,
 url: some.php,
 data: name=Johnlocation=Boston,
 success: function(msg){
   alert( Data Saved:  + msg );
 }
   });

  If the authentification is based on .htaccess, you can use 
  username/password
  option

  Pierre

  W. C. Fields  - I cook with wine, sometimes I even add it to the food.

  2008/11/25 TheBlueSky [EMAIL PROTECTED]

   Hi everyone,
   How can I send login credentials with jQuery Ajax request (get(), post
   () or ajax()) when the page I'm requesting is asking for them before
   permitting the access.
   Note here that I'm not talking here about form-based authentication.
   Thanks in advance.- Hide quoted text -

  - Show quoted text -- Hide quoted text -

 - Show quoted text -



[jQuery] Re: Doing Ajax call to a page that requires authentication

2008-11-27 Thread Karl Rudd

Is the page/resource in another domain? That would obviously not work.
That's the only thing I can think of.

Karl Rudd

On Thu, Nov 27, 2008 at 9:20 PM, TheBlueSky [EMAIL PROTECTED] wrote:

 Thanks for your reply.

 Sorry that my question wasn't clear enough; I already tried using the
 username/password options for ajax() method, however, I'm getting
 'Permission denied to call method XMLHttpRequest.open' kind of
 message. I don't know if there is something else need to be done or
 not.

 By the way, the credentials I'm using are correct.

 On Nov 25, 4:24 pm, Pierre Bellan [EMAIL PROTECTED] wrote:
 Hi,
 If the authentification is form-based, then the login credentials is passed
 by GET or POST.
 So you just have to add it to your ajax request

 see the data option.

 $.ajax({
type: POST,
url: some.php,
data: name=Johnlocation=Boston,
success: function(msg){
  alert( Data Saved:  + msg );
}
  });

 If the authentification is based on .htaccess, you can use username/password
 option

 Pierre

 W. C. Fields  - I cook with wine, sometimes I even add it to the food.

 2008/11/25 TheBlueSky [EMAIL PROTECTED]





  Hi everyone,
  How can I send login credentials with jQuery Ajax request (get(), post
  () or ajax()) when the page I'm requesting is asking for them before
  permitting the access.
  Note here that I'm not talking here about form-based authentication.
  Thanks in advance.- Hide quoted text -

 - Show quoted text -


[jQuery] Re: Replacing document.getElementById()

2008-11-24 Thread Karl Rudd

The $('#id'), or jQuery('#id'), function returns a special jQuery
collection (which acts much like an array in some ways). It does not
return an actual DOM node.

jQuery is a library that helps you select things (via CSS selectors)
and do stuff (usually all at once) to those things.

To check if there was any DOM node selected use:

  var o = $('#myid');
  if (o.length != 0) {
// do something
  }

To get the first DOM node out of a jQuery collection use:

  var theNode = $('#myid')[0];

To select multiple objects pass in a string of selectors (just like in CSS):

  var myNodes = $('#checkInDate-Deal, #checkOutDate-Deal');

To change an attribute of the selected nodes you can either use the
attr() method:

  myNodes.attr('value', 'mm/dd/');

Or in this case, there is a shortcut method:

  myNodes.val('mm/dd/');

Something to watch out for is that the each() method (when called on
a jQuery collection object) actually returns the raw DOM nodes,
one at a time. ie:

  myNodes.each(function() {
// this == a raw DOM node
  });

Karl Rudd

On Tue, Nov 25, 2008 at 12:13 PM, halcyonandon [EMAIL PROTECTED] wrote:

 Hi,

 I'm trying change all instances of document.getElementById() with
 the jQuery's DOM traversal syntax, however it breaks it everytime.

 A simple example is this function:

rm: function(){
var m = document.getElementById('discountMonth');
if(m)
m.selectedIndex = 0;
}

 If I change document.getElementById('discountMonth'); to $
 ('#discountMonth');  or any variation of that it breaks.(I tried
 single and double quotes as well as attempting to get the element by
 class and so forth with no luck).

 The HTML looks like this select onchange=$.bots.rd();return false;
 id=discountMonth name=deals[discountMonth]
 class=input_deals_dropdownoption value=//select.

 The more troublesome issue is with a function like this

rd: function (){
var ds = new Array('checkInDate-Deal', 'checkOutDate-Deal');
$(ds).each(function(i){
el = document.getElementById(ds[i]);
if(el)
el.value = 'mm/dd/';
});
}, ...

 With the HTML looking like input type=text onblur=$.bots.rm
 ();return false; id=checkOutDate-Deal value=mm/dd/
 name=checkOutDate class=input_deals/

 Any help understanding jQuery's DOM traversal especially with regard
 to array iterations would be much appreciated, thanks.




[jQuery] Re: setInterval method call with parameters not working

2008-11-23 Thread Karl Rudd

The setInterval() function can take a string (which is evals) or a
reference to a function (which is the recommended way).

To invoke a function via setInterval/setTimeout with arguments what is
usually done to use an anonymous function/closure.

So something like:

slideshow_interval = setInterval(
  function() {
PageMethod(getNextSlideShowItem, [elmID, callerID,
CampaignID, hdnCampaignID], onSuccess, onFail);
  ),
1000);

On a side note: I wouldn't recommend loading via ajax at such a small
interval (1 second). In the real world the response will frequently
end up taking more than 1 second to return from the server.

Karl Rudd

On Mon, Nov 24, 2008 at 7:07 AM, Sean [EMAIL PROTECTED] wrote:

 HI There,

 I'm trying to call a method using the setInterval function that call
 has some parameters but I can't get it to work. Can someone give me a
 hand with the syntax please.

 Sean

 slideshow_interval = setInterval( 'PageMethod(getNextSlideShowItem,
 [elmID, callerID, CampaignID, hdnCampaignID], onSuccess, onFail)' ,
 1000);


 function PageMethod(fn, paramArray, onSuccess, onFail)
  {

   var pagePath = window.location.pathname;
   var paramList = '';
   if (paramArray.length  0)
   {
 for (var i=0; iparamArray.length; i+=2)
 {
   if (paramList.length  0) paramList += ',';
   paramList += '' + paramArray[i] + ':' + paramArray[i+1] +
 '';
 }
   }
   paramList = '{' + paramList + '}';

$.ajax({
type: POST,
  //  url: WebForm8.aspx/getNextSlideShowItem,
url: pagePath + / + fn,
data: paramList,
contentType: application/json; charset=utf-8,
dataType: json,
success: onSuccess,
fail: onFail
});
}
  });



[jQuery] Re: Do i need to unbind event before removing DOM element

2008-11-21 Thread Karl Rudd

jQuery will take care of the cleanup.

Karl Rudd

On Sat, Nov 22, 2008 at 2:48 PM, George [EMAIL PROTECTED] wrote:

 I am creating dynamicly span tag and binding click event.
 $('#myspan').bind('click', param, myFunc);

 Then at some point this span is removed using JQuery. Do i need to
 unbind click event first?
 Or it's ok and Javascript will clean that up automaticly..

 George.


[jQuery] Re: Resize an element without affecting the layout

2008-11-19 Thread Karl Rudd

Tables at difficult beasts, they're built to expand with their content.

If you want an image that is in a table cell to (appear) to expand
over the top of (and outside the bounds of) the cell then you'll have
to something like:

  - duplicate the image element
  - insert the duplicate image outside the table
  - position the duplicate image absolutely over the top of the cell/image

Karl Rudd

On Thu, Nov 20, 2008 at 4:52 AM, vani [EMAIL PROTECTED] wrote:

 Thanks for replying, but I'm still having trouble making it work. I
 tried to set the table to relative and img to absolute but it didn't
 work as intended.
 This is the layout of the table:
 table
 tr
 tddivimg //div/td
 tddivimg //div/td
 tddivimg //div/td
 /tr
 /table

 ...I'm trying to resize the img elements.

 On 19 stu, 18:15, Liam Potter [EMAIL PROTECTED] wrote:
 use absolute positioning and set the parent element to relative.



 vani wrote:
  Is it possible to create an animated resize of an element without
  affecting the layout of the parent element table?
  I'm using jQuery 1.2.6 and possibly personalized jQuery UI, if
  necessary.


  1   2   3   4   >