[jQuery] Masked Input plugin, changing values

2010-01-14 Thread Brett Ritter
I have a user request that a month entry (99/) allow the user to
input just a single-digit month (9/) and the page will auto-pad.

Thus if I type "1/1999" I should get "01/1999".
In general, I'm trying to use the masked input plugin all around.

I thought I'd just place a keydown event to trigger on the "/" and
modify the input value to insert the preceeding zero, and let the
plugin run as normal.  Unfortunately the plugin events maintain an
internal idea of the state of the field, so this doesn't work.

Removing and reapplying the mask wipes the existing value of the field.

I can tweak the plugin to do what I want, but now I'm running a fork.
Has anyone else dealt with this?  Am I missing an obvious way of doing
this?

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] [Masked Input] Variable length fields / inner padding

2009-12-16 Thread Brett Ritter
I have a set of odd requests from my users:

The first request is that we have a date field: mm/dd/, BUT we
accept short dates and pad appropriately with 0:
1/1/2009 becomes 01/01/2009.

Checking for these cases server-side is easy enough, but I'd really
like to provide some friendly masking and validation up front.

The Masked Input plugin has a completed() callback, but that won't
help in case #1 (1/1/2009 isn't valid input with a mask of 99/99/,
and isn't "complete").  What I really need is to react to the "/"
character being pressed and pad the section before it, hopefully
without having to effectively rewrite the plugin.

Ideas?

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


Re: [jQuery] Re: Problem with plugins

2009-11-27 Thread Brett Ritter
On Mon, Nov 23, 2009 at 5:55 AM, Paulodemoc  wrote:
> Its the javasscript on the php page, and the only php there is to
> output the urls, and these urls are being printed correctly
> The url doesn't affect the understanding of the rest of the code...

If your plugins aren't loading, those URLs are quite likely involved.
We have no way of knowing if they are indeed working since we don't
see the output.

Try sending the HTML the browser is getting.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: how to replace all the '[]' to be '' in $.SortSerialize('MDEExportedList').hash

2009-10-01 Thread Brett Ritter

On Thu, Oct 1, 2009 at 1:18 PM, Junhua Gao  wrote:
>  I use $.SortSerialize('MDEExportedList').hash.replace('[]','')
>   but only the first one is replaced.

I thought replace() only replaced the first instance unless a regex
with global flag was used.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Way to "convert" DOM event to jQuery event?

2009-09-24 Thread Brett Ritter

On Thu, Sep 24, 2009 at 12:10 PM, Kevin Dalman  wrote:
>
> If you need data for multiple fields, then a 3rd option is to create a
> single hash/data object for the page and writing all your data into
> that. This makes your data easy to read and debug, and is highly
> efficient because you don't have to 'parse' anything...

And while all of the above are true, a 4th (not necessarily better)
option is to have a 

[jQuery] Re: Browser sniffing - the correct way?

2009-09-18 Thread Brett Ritter

On Thu, Sep 17, 2009 at 9:53 AM, ldexterldesign
 wrote:
> browser and serve up a load of new CSS. Opera doesn't support negative
> vertical span margins, so I'm gonna have to reduce the font-size of
> some text.

And there you have a focus: You don't want to detect Opera, you want
to detect whether a browser supports negative vertical span margins.

I don't know which clause will do that :), but that's what you're
looking to do. That way your code will continue to work as desired in
the future when Opera address this issue and/or when another browser
displays the same issue.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: jQuery PDF Viewer?

2009-09-17 Thread Brett Ritter

On Wed, Sep 16, 2009 at 11:19 PM, benji++  wrote:
>
> It seems that I've answered my own question…  I realized that, as
> Jeffrey Kretz mentioned, I needed to rely on Flash to do the PDF

So you solved the problem of requiring a PDF plugin on the client by
requiring a Flash plugin on the client?
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Browser sniffing - the correct way?

2009-09-17 Thread Brett Ritter

On Thu, Sep 17, 2009 at 7:02 AM, ldexterldesign
 wrote:
> I wondered if anyone would be kind enough to point me in the direction
> of a good browser detection script/plug-in/tool? I've heard/read
> jQuery.browser isn't the way to go with the latest jQuery (v.1.3.2).

.browser() still works, the reason it's not the way to go is that
jQuery has shifted to .supports(), which covers feature by feature.
After all, you're probably sniffing not because you care which browser
they are using, but because you care if their browser supports a
certain feature.

Check out the docs on .supports()

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Sorting in jQuery

2009-09-11 Thread Brett Ritter

On Fri, Sep 11, 2009 at 8:32 AM, vsnu  wrote:
> I need to sort  tags by their class names
> Please help me !

I found this:

http://www.mail-archive.com/disc...@jquery.com/msg05470.html

but the linked bug report says that solution no longer works.

Offhand I'd guess you could use the same approach:

Use the sort() method of the array class and pass in the Jquery
elements (gotten via get())

As this seems a common and simple need, I'd guess someone has written
a plugin for it, have you tried this?

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

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


Re: FW: [jQuery] Re: Newbie: Cannot get .text() to work with IE7

2009-09-10 Thread Brett Ritter

On Thu, Sep 10, 2009 at 8:21 AM, Knight, Doug  wrote:
> Sure could use some help on this one. Does anyone on the list have any clue
> why the .text() function works differently between FF and IE7? I’ve

Okay, so here's the basics:

It isn't .text(), that's just showing the problem.

The problem is your $(xml) call.

As I understand it, Jquery relies on the underlying DOM parser of the
browser.  Non-IE browsers handle XML casually, IE browsers are more
specific. (as easy as it is to rip on MS/IE, I'm not convinced the IE
behavior is wrong, per se, but it's clear that being right doesn't
make things easier).

Google for "JQuery IE XML Parsing" returns a fair number of hits on
this if you want to delve in deeper.  Sadly it looks like the answer
is a little complicated.

http://docs.jquery.com/Specifying_the_Data_Type_for_AJAX_Requests

The above link covers your exact case and shows a work around for
loading local files - it may behave differently on a server.  I've not
played with it myself as of yet.

Sorry you didn't get a faster response.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: HTML code inside script tag, how access to it with DOM???

2009-09-10 Thread Brett Ritter

On Wed, Sep 9, 2009 at 6:08 AM, Mariano  wrote:
>       
>           <div id="test">some test</div>
>       
> Now I have the will to access to the text inside test div but the code
> $('#test').text();
> doesn't work, matter of fact nothing is returned.

The contents of the script tag aren't part of the DOM...but they are
part of the script tag, which itself is part of the DOM.

So slap an id on that script tag and you can grab the contents.  You
can put the contents into a jQuery call and use .find() or related
methods to snag what you need.

I'm a big fan of doing this in small controlled blocks to avoid
embedding lots of HTML into my javascript, but it does take some
practice to find the correct balance between useful separation and
unnecessary/unhelpful separation.  Like you I do NOT label it with
text/html - while that might work now, text/html might end up a known
definition at some time, changing behavior.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Get the input value of "ANY" element tag

2009-08-25 Thread Brett Ritter

On Tue, Aug 25, 2009 at 11:49 AM, ArySal wrote:
> What do you mean "By the way, it is not reccomanded to have more then
> one element with same id ", could you recommend a tutorial or pointers
> where I can get this function working please

HTML elements can have "id" attributes and "class" attributes to identify them.
"id" attributes should be unique within the document, while many
elements can share class attributes.

Searching for "id vs class" should get you some useful links on the topic:

http://www.google.com/search?q=id+vs+class

I don't know if this issue is related to your problem, but it is a
good idea to fix this regardless.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: App like hangman

2009-08-24 Thread Brett Ritter

On Mon, Aug 24, 2009 at 11:24 AM, Boris Trivic wrote:
> I can success print ui.draggable to console, but how to convert it to
> string?
> I need to write it into some element with .innerHTML and I will
> probably use it in "for" loop...

I think you are trying the hard way.

ui.draggable is not a string, but a jQuery element.  Use that as you see fit.

For Hangman you're probably looking to copy either the text  (
ui.draggable.text() ) or the html itself ( ui.draggable.html() ).  If
you need to clone the source you want ui.draggable.clone() (note that
any events bound to the original are not bound to the clone unless you
use live() )

Trying to convert a jQuery element to a string doesn't make sense
unless you say what "string" you want - the text, the html, the id,
these are all different strings.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: App like hangman

2009-08-23 Thread Brett Ritter

On Wed, Aug 19, 2009 at 11:07 AM, Boris Trivic wrote:
> When I take on of draggable divs and put it on 3rd div (fixed), how I
> can get ID of that div which is dragged on 3rd div.

Ah! Now I understand.  (Good examples).

Sadly, Drag-and-drop is not something I've played with.  However, from
looking at the jqueryUI docs, it appears what you are looking for is
the "Droppable" plugin, which receives "draggable" objects:

http://jqueryui.com/demos/droppable/

Hope that helps!

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: App like hangman

2009-08-19 Thread Brett Ritter

On Wed, Aug 19, 2009 at 9:40 AM, Boris Trivic wrote:
> anyone? :s

I'm afraid I'm not understanding your question.  Can you provide
simple html that you are trying to read/manipulate?

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: POST GET help

2009-08-13 Thread Brett Ritter

On Thu, Aug 13, 2009 at 4:43 PM, Dave Maharaj ::
WidePixels.com wrote:
> $('#JobQuery').keyup(function(){
> $.post("/jobs/search/", $("#JobSearchForm").serialize());
> });
...
> can I get the data in the response to load into a div?

The third parameter to $.post is a callback function that is called on
success and is passed the resulting data.  Check
http://docs.jquery.com/ or http://visualjquery.com/ for more details
on the callback and what it is passed.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Script not recognizing class

2009-08-13 Thread Brett Ritter

On Thu, Aug 13, 2009 at 1:18 PM, Simon wrote:
>          class="notloaded">1
...
> What am I doing wrong?

You are using multiple class="" declarations in your tags.

You want instead:


-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Best way to add attributes/extend element

2009-08-13 Thread Brett Ritter

On Thu, Aug 13, 2009 at 12:44 PM, twooton wrote:
> When  you need for a certain element (say a text input box) to
> remember some data, what is the best way to do this? Can you extend
> the input box object with jquery? Right now i've been storing it in
> the rel tag $('#testInput').attr('rel','extrainfo') it just seems like
> there should be a better way to do this. Any suggestions?

Check out data() method on Jquery objects...

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Transforming input as it's typed

2009-08-12 Thread Brett Ritter

On Wed, Aug 12, 2009 at 4:14 PM, Richard D. Worth wrote:
> You might take a look at the mask plugin by Andrew Powell in the jQuery UI
> Labs
> http://wiki.jqueryui.com/mask

Indeed I might!  This looks very interesting.  The only feature that
calls to me that I don't see supported is metadata in the markup, and
I'll dig around the metadata plugin to see if it's automagical
(haven't worked with it yet).  Masked input had been interesting but
lacked the transformation aspect, this takes care of that.

Very interesting, thank you!

(That said, if anyone has critiques off my code I'm still interested
from a learning perspective)
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Transforming input as it's typed

2009-08-12 Thread Brett Ritter

My workplace has a lot of people doing manual entry.  I'm looking to
provide some friendly automatic formatting of data as they type it.

I have working code (thus far) but I want to ensure I'm doing things
in a sane way (there's a surprising amount you can do insanely that
still works :) ).

Here's a function below that transforms a phone number - the worker
enters the digits(only), the field reflects (and could also accept)
the fully formatted version (e.g. (123) 456-7890 ).
I'm building this towards a plugin model (ala masked input with happy
coexistence with validate)

$("#example").keyup(function(){
var val = $(this).val();
if(/^[-\d\(\) ]*$/.test(val)){
var base = val.replace(/[-\(\) ]/g, '');
var size = base.length;
if(size < 3){  // Area code
// Leave unchanged
}
else if (size < 6){
val = "(" + base.slice(0,3) + ") " + 
base.slice(3);
}
else if(size < 11){
val = "(" + base.slice(0,3) + ") " + 
base.slice(3,6) + "-" + base.slice(6);
}
    $(this).val(val);
}   
});

Comments appreciated.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Error when trying to download jquery

2009-08-12 Thread Brett Ritter

On Wed, Aug 12, 2009 at 1:43 PM, mrbutler wrote:
> Sorry, shouldn't have said 'run'.  After I save jquery-1.3.2.min.js, I
> right click on it, select open,
> then the error pops up.

That's running :)

Jquery is a javascript library, meaning that it's a plain text file
that can't be executed.
If it linked to via an HTML document, which is in turn loaded and
parsed by a browser, the library functions are available to any
javascript on that page.

If you pick "open with", say, notepad, you can see the jquery (which
will not be remotely interesting to look at, particularly the .min.js
version).

The jquery.com site has some good tutorials to get started with it,
but don't expect the file itself to "do" anything.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: How to specify a default value...

2009-08-11 Thread Brett Ritter

On Tue, Aug 11, 2009 at 12:10 PM, Rick
Faircloth wrote:
> What I still don't understand is even how this logic works:
>
> if ( row[19] ) {
> row[19]
> } else {
> N/A
> }

The key part is  "if( row[19] )".  row[19] is being evaluated for
_truth_.  Javascript defines (I believe) truth to be "non-false", and
false is defined as any of:
undefined
null
0
"0"  (a string with value zero..I think.  I may be channeling Perl here)
"" (empty string)
false (boolean value)

So if you are trying to provide a default value in the case of null
only, then you should check for null because any of the other "false"
(non-null) values will give you your provided default instead.

The ( test ? return if true : return if false ) construct allows a
full test, so:

( row[19] == null ? "default" : row[19] ) works.

If you want to look up more about this sort of construct, it's called
the "ternary operator" and exists in many programming languages.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: jQuery and the 'this' keyword

2009-07-30 Thread Brett Ritter

On Thu, Jul 30, 2009 at 3:51 PM, #micah wrote:
>
> Would you recommend using the .bind(type, data, fn) function to
> achieve what i'm trying to do? Or could you steer me in the right
> direction? I'm surprised that the .click() works in that manner. How
> would you dynamically assign that function to that button?

I believe you're encountering a disconnect between how Javascript (not
Jquery) works and what you expect (likely based off of other
programming languages).

When inside a function that is contained in an object (a "method"),
"this" does NOT refer to the object your function is part of.  If you
expect it to you will encounter much confusion.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: JQuery BREAKS in IEx -- H E L P!!!!

2009-07-30 Thread Brett Ritter

On Thu, Jul 30, 2009 at 11:11 AM, PictureMan wrote:
> It works great in FF, but not in IE!!! What can I do to fix? There's
> too much code to post online. But I can tell you about it's
> conctruction..  It's a mix of ColdFusioin and JQuery.
...
> }};
> }};
> 

The above endings are syntax errors, but I'll assume that's the result
of hand-copying...

...In other news, if you are running ColdFusion to dynamically
generate the JS, why not just dynamically set the form elements in the
first place?  Just curious.

Otherwise:

1) Define "not in IE".  What is the behavior you observe?
2) Check the generated HTML that results.
3) Try to pare down the generated HTML into a small example that
easily demonstrates the problem.

Generally in the course of #3, a great many problems are discovered
and fixed.  If not, you'll have a simple example that will be much
easier to get help with.

Hope that helps!

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: [treeview] Collapsed tree will flash before collapsing. Anyway to avoid it?

2009-07-30 Thread Brett Ritter

On Wed, Jul 29, 2009 at 7:39 AM, Pablo wrote:
> Is there a way to avoid that, thus showing only the collapsed tree
> from the start? Or to make it invisible until the moment it is
> collapsed?

(grumble) I saw a great tutorial on this just a few days ago and now I
can't find it.  Perhaps someone here can remind me?  I know Resig's
book (Pro Javascript Techniques) has this as well.

I've not used treeview, but the same issue exists with any
on-refresh/load display modifications.  Hopefully this works with
treeview as well.

Anyway, here are the basic principles:

Step 1: You can hide the element (or some wrapping div or whatnot)
with CSS (display:none) from the start, run the treeview code, then
unhide the wrapper.

BUT this is poor usability because you've now disabled the element for
anyone using a browser WITH css support but NOT javascript support.

So you go to:

Step 2:  You have early-running javascript apply the hiding CSS.
Don't stick this in ready(), just stick it in the document.  It should
execute prior to ready().

There are refinement efforts you can do from there, but that should
get you working.

...Wish I could find that tutorial.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Selector question

2009-07-29 Thread Brett Ritter

On Wed, Jul 29, 2009 at 4:23 PM, lukas wrote:
> How can I pick an id element (here #bridge1,#bridge2) and toggle its
> child (here a p element) without actually using the id element as
> parent?
> 'this > p' apparently does not work.

$(this).children("p")

It only checks immediate children (as with ">").  For further
descendants use .find() instead.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: POST data not being sent

2009-07-29 Thread Brett Ritter

On Wed, Jul 29, 2009 at 1:48 PM, shaf wrote:
> Ok guys, thats for the advice and replies.
> Cesar, if thats how you construct a GET string how would I construct a
> POST string ?

You don't need a single string.

$.ajax({
type: "POST",
async: false,
url: _HOMEDIR+"send.php",
data: {
  aParameter: "somevalue",
  anotherParamter: "someothervalue"
},
dataType: "json",
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: function running 2X

2009-07-29 Thread Brett Ritter

On Wed, Jul 29, 2009 at 3:03 PM, marksimon wrote:
>
> Still getting 2 alerts.

You show your .click() function in another...is that wrapping function
getting called more than once?  If so, the action is getting bound
more than once.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: POST data not being sent

2009-07-29 Thread Brett Ritter

On Wed, Jul 29, 2009 at 12:16 PM, Liam Potter wrote:
> also, don't delete the quoted
> posts, means everyone not using a web based group reader can follow the
> conversation.

However feel free to TRIM lengthy posts to the relevant parts.
Even non-web-based group readers support threading or sorting by
conversation, and a hint as to which part of the thread you are
replying to is sufficient.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: hoverIntent not working?

2009-07-28 Thread Brett Ritter

On Tue, Jul 28, 2009 at 9:43 AM, Brian Cherne wrote:
> So when you send it only one function (which .hover() seems to handle just
> fine) hoverIntent thinks you're sending a configuration object. Try adding a

I believe that's a fairly recent change to hover().  Prior behavior
required 2 functions (and people made this same mistake anyway, thus
the change).

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Validation with rewriting

2009-07-27 Thread Brett Ritter

On Mon, Jul 27, 2009 at 6:06 PM, Jörn
Zaefferer wrote:
>
> Having JS sanitize for the backend is somewhat dubious, I'd not go
> there, but you probably don't want to discuss that.

I think we're in agreement there, actually.  JS provides no security
and shouldn't be relied on.  Rather I'm looking at a progressive
enhancement feature:  Server-side validation can reject (for example)
any CC Number that isn't 16 digits.  User's w/o JS can get the
functional basics ("please enter your CC number without hyphens or
spaces") The JS front end will accept multiple formats (16 digits, 4
sets of 4 digits with whitespace, etc) and translate them to what the
server demands.

This is more impressive with string inputs for dates, phone numbers,
etc.  Typing "8005551212" is easy on the user, and seeing "(800)
555-1212" is better for their visual parsing.

> Anyway, a validation method has access to the validate element, so you

Ah, this is the essential piece I was missing.  I'll code a few tests
and report back in a few days.  Thanks for the help!

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Validation with rewriting

2009-07-27 Thread Brett Ritter

On Mon, Jul 27, 2009 at 5:20 PM, Jörn
Zaefferer wrote:
> You could start by writing custom methods for each of these input
> types, and where possible, delegate to the existing methods:
> http://docs.jquery.com/Plugins/Validation/Validator/addMethod

If I'm following you, you're saying to have validation that accepts
the "loose" input and considers them all "valid".  That doesn't help
me sanitize for the backend though.
On submission, that Phone number should come across as the "proper"
format.  This also complicates the validation methods considerably.

Or am I misunderstanding you?

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Validation with rewriting

2009-07-27 Thread Brett Ritter

I considering input rewriting (transformation, conversion, etc, use
the verb of your choice) to be an essential part of validation.

This means phone numbers, SSN, dates, credit card numbers, etc should
all accept "loose" input types and should be standardized for backend
processing.
(Personal Pet Peeve - sites that instruct you not to use spaces or
hyphens in credit card numbers)

This article makes the general case:

http://www.hising.net/2007/03/30/form-validation-with-javascript/

The article for the popular validation plugin notes the above article,
but doesn't offer code for this particular point (See #6):

http://bassistance.de/2007/07/04/about-client-side-form-validation-and-frameworks/

It does point out the masked input plugin, but my goal is not to
provide hints to the user on how to take additional effort but rather
to save them effort in the first place.

Both of these articles date from 2 years ago.  Googling for existing
plugins has not led me to happiness.  I'll happily write my own plugin
if it is not reinventing the wheel, but I'd love to have some
compatibility with the validate plugin.
Does anyone have suggestions for the best approach for doing so?  The
transformation can be done front-end (i.e. visible to the user,
changing the value in the inputs) or internally (standardizing the
values sent to the validate plugin), I'm not picky as to which just
yet.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: I dont understand why this doesnt work.

2009-07-18 Thread Brett Ritter

On Fri, Jul 17, 2009 at 4:09 PM, Mike wrote:
> and FireBug, something is replacing GET with OPTIONS.  But in IE and
> Opera, it is still showing up as GET.  I dont get it

As mentioned, the Same Origin Policy is killing the request.  The
OPTIONS part is because FF3.5 now allows a workaround to SOP:

http://www.petefreitag.com/item/703.cfm

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: manipulate the next element with a class

2009-07-15 Thread Brett Ritter

On Wed, Jul 15, 2009 at 6:00 PM, Benn wrote:
>
> Is there a non-structure specific way of finding the next element with
> a given class?

Try this out (Haven't tested, but the find() method is probably what
you are looking for)

$(document).ready(function(){
  $(".link1").click(function(){
$(this).find(".a1").css({"visibility":"hidden"}); //hides all a1's
but keeps the space
  });
});

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Using jQuery to completely separate HTML from Javascript

2009-07-15 Thread Brett Ritter

On Mon, Jul 13, 2009 at 10:18 AM, Thierry wrote:
> $(document).ready(
>  function() {
>    $("a.foo").click(foo());
>  }
> )

This is probably not quite what you desire, as it will call foo()
immediately, not on click.

use $("a.foo").click(foo);// <--Note 'foo', reference to function, not
foo(), call to function.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Detecting a redirect response to an Ajax query

2009-07-15 Thread Brett Ritter

On Wed, Jul 15, 2009 at 12:38 PM, candlerb wrote:
> Is there any way to be able to detect in $.ajax whether the response
> involved a HTTP redirect?

A redirect should return some form of 30x Header (as opposed to a 200
OK).  You can check that, which is more elegant than looking for login
page text, but not really what you seek.

To make life more difficult, that Header is in the XHR object, so you
can only check it in the complete() callback (I believe).

Otherwise I'm unaware of any solution.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: <3 Solitaire

2009-07-15 Thread Brett Ritter

On Wed, Jul 15, 2009 at 12:42 AM, Karl Swedberg wrote:
> Interesting view about this from Douglas Crockford:
...
> language in all browsers has been JavaScript. In XHTML, this attribute is
> required and unnecessary. In HTML, it is better to leave it out. The browser
> knows what to do.

That is interesting.  I wonder why it is "better" to leave it out,
even if the default works?  As a general rule I always thought there
is nothing wrong with explicit, particularly if it is non-onerous, and
even more so on something regularly changing, such as Web practices.

And how would this interact with Resig's advice to use unknown script
types to stick content into the page that would not be
displayed/read/used/etc by default? I just discovered that trick and
was hoping that would provide me the final solution to not including a
lot of markup in my JS.

http://ejohn.org/blog/javascript-micro-templating/

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: <3 Solitaire

2009-07-14 Thread Brett Ritter

On Tue, Jul 14, 2009 at 6:37 PM, weepy wrote:
>
>> you don't define a type here making your page invalid
> Are you referring to $().ready(function() { }) ?  You mean you'd

I believe he's referring to the script tag itself.  It should given a
type (e.g. "text/javascript")

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Simple selector problem

2009-07-10 Thread Brett Ritter

On Fri, Jul 10, 2009 at 11:34 AM, Chris wrote:
> I'm using jQuery 1.3.2.  In IE, this returns 3.  In Firefox, it
> returns 4.

Are you running Firebug or any add-on that modifies the DOM in Firefox?
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: both 'if' and 'else' blocks being executed

2009-07-10 Thread Brett Ritter

On Fri, Jul 10, 2009 at 6:09 PM, Matthew wrote:
>
> Depending on how your serverside processing works it makes sense that
> it would process both. Doesn't disable just prevent a client-side user
> from changing the checkbox?

Disable instructs the browser not to send it.  Readonly prevents
client-side edits.

That said, I think different browsers enforce this to different levels.  YMMV.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org