Re: [jQuery] Sound

2009-11-05 Thread Erik Beeson
No jQuery necessarily needed for this. Plenty of information here:

http://www.google.com/search?q=html+embed+audio

--Erik


On Thu, Nov 5, 2009 at 3:04 PM, shapper  wrote:

> Hello,
>
> Is it possible to have a music on a HTML page with two buttons to play/
> stop?
> Can I use JQuery for this?
>
> Thanks,
> Miguel
>


Spam increase (WAS: Re: [jQuery] Re: XXX hot sexy banned movie XXX)

2009-09-29 Thread Erik Beeson

Some of my servers are seeing a lot more DDoS type traffic and I'm
seeing a lot more spam across all of the mailing lists that I'm on.
It's seeming like something is going on.

--Erik


On Tue, Sep 29, 2009 at 4:09 PM, Mike Alsup  wrote:
>
> Sigh..   this message was *not* sent by me.   And I've just changed my
> Google password so hopefully it won't happen again.
>
> Mike
>
> On Sep 30, 6:24 am, "mal...@gmail.com"  wrote:
>> hot sexy banned movie
>


[jQuery] Re: Synchronous call in JQuery?

2009-09-28 Thread Erik Beeson

Your question doesn't make very much sense. In your example,
doSomething2 would execute after doSomething1 finished, so it is
synchronous.

Perhaps you could provide an example of what you're actually trying to do?

--Erik


On Mon, Sep 28, 2009 at 6:24 AM, Mesquite  wrote:
>
> Is there a JQuery way to execute a custom function 'after' another
> custom function is executed?
> The second function must wait until the first one has finished. (Not
> asynchronous but synchronous)
> Important: I don't want place the call to the second function in the
> first one.
>
> for example:
>
> doSomething1();
> doSomething2();
>
> function doSomething1() {
> }
>
> function doSomething2() {
> }
>


[jQuery] Re: Web Application GUI's

2009-08-14 Thread Erik Beeson
I do 2 kinds of webapps: very "rich" (or "heavy") desktop-replacement type
apps, for which I generally use EXT, and much lighter, javascript-optional
type websites, for which I generally buy a template from ThemeForrest.
--Erik


On Fri, Aug 14, 2009 at 1:15 PM, Meroe  wrote:

>  Hello all,
>
>
>
> I assume I'm like many of you.  I'm able to write code, but when it comes
> to design I am at a loss.  I've seen some really neat layouts such as
> mochaui and extjs examples, but I'm struggling to put together one I'm happy
> with.
>
>
>
> I'm using the jquery UI layout to set up my north, west, east, etc but
> after that I'm struggling to find a design I like and one I feel will fit
> the application.  So, I'm reaching out to this group to see if anyone has
> links to examples, videos, or even ideas on good layout design that could
> assist me in moving past my "writers block" for my application.
>
>
>
> Have a wonderful weekend!
>
>
>


[jQuery] Re: Need help cuz I don't get 'this'

2009-06-14 Thread Erik Beeson
Like MorningZ said, more info would be helpful, but this should work:

$('#output').html('SRC: ' + $(this).children('img').attr('src'));

--Erik


On Sun, Jun 14, 2009 at 7:02 AM, Logictrap  wrote:

>
> I need to get the src attribute of an img element that is a sub-
> element of 'this' but I can't figure out how to traverse 'this' to get
> there.
>
> The contents of 'this' are:
>
>  height="200" alt="beach" />
>
> this works:
>
> $('#output').html("ID: " + this.id);
>
> This does not:
>
> $('#output').html("SRC: " + this.img.src);
>
> How do I get the contents of the img.src attribute'?


[jQuery] Re: Wait for one function to finish, then start the next....

2009-05-24 Thread Erik Beeson
As you've probably found, there is no sleep/wait/pause in JavaScript. The
whole system is single-threaded, so any sort of "sleep" would hose the whole
system.
Your original statement doesn't actually make sense. As it is, function2
*doesn't* execute until open_popup returns, so that isn't really your
problem. It sounds like you want function2 to execute after something setup
within open_popup happens, which you would do with a callback.

Good luck.

--Erik


On Sun, May 24, 2009 at 6:57 PM, macphreak  wrote:

>
> No, it doesn't involve Ajax. Although I wish it did. It would be a lot
> easier for me to define a call back then. :)
>
> This is code that I have to work with (or work around I should say)
>
> Thanks again for any helpful hints!
>
> On May 24, 6:33 pm, Ricardo  wrote:
> > what's the code for open_popup? does it involve ajax?
> >
> > http://www.ibm.com/developerworks/web/library/wa-ajaxintro2/#N103A2
> >
> > On May 23, 2:42 pm, macphreak  wrote:
> >
> >
> >
> > > I have seen a few of threads on this issue. However, they have mostly
> > > deal with the fadeins or fadeouts which is not what I am needing. Here
> > > is what I need:
> >
> > > On a click event, start function 1. Then after it's finished, start
> > > function2. Here is my code:
> >
> > > var $j = jQuery.noConflict();
> >
> > > $j(document).ready(function(){
> > > $j("#select_inv").click(function() {
> > > open_popup("Inv_Inventory", 600, 400,
> "", true, false,
> > >
> {"call_back_function":"set_return","form_name":"EditView","field_to_name_ar
> ray":
> > >
> {"id":"inv_inventory_id_c","name":"name_c","make_c":"make_c","model_c":"mod
> el_c","year_c":"yearmanufactured_c","bodystyle_c":"bodystyle_c","vin_c":"vi
> n_c","miles_c":"odometer_c","exteriorcolor_c":"exteriorcolor_c","interiorco
> lor_c":"interiorcolor_c","trim_c":"trim_c","stocktype_c":"conditionstocktyp
> e_c"}},
> > > "single", true);
> > > function2();
> > > });
> > > });
> > > });
> >
> > > Right now, it runs the open_popup function fine. However, it runs
> > > function2() immediately. I need it to wait until the open_popup
> > > function is finished, and then run the function2() script.
> >
> > > Any help would be greatly appreciated!  Thanks!
>


[jQuery] Re: Count how many checkboxes are checked

2009-04-15 Thread Erik Beeson
categoryList.is(':checked') will return false if none are checked, so you
could do:

heading.css('color', categoryList.is(':checked') ? 'red' : 'black');

--Erik

On Wed, Apr 15, 2009 at 8:33 AM, Dragon-Fly999 wrote:

>
> Hi, I'm new to JQuery and I have a question about checkboxes.  I have
> 5 checkboxes on my page and they are passed into my plug-in.  I'd like
> to find out how many of them are checked in my plug-in.  The following
> code works but I'm sure there is a better way to do it (especially the
> part of the code that figures out the number of checkboxes checked).
> Any suggestions would be appreciated.  Thank you.
>
> =
>
> In my aspx page:
>
>// $('.category-list') returns a list of 5 checkboxes.
>$(function() {
>  $('#info-heading').createCategoryGroup($('.category-list'));
>});
>
> =
>
> In my plug-in:
>
> // categoryList is a list of checkboxes.
> (function($) {
>  $.fn.createCategoryGroup = function(categoryList) {
>
>var heading = this; // This is an anchor.
>
>// Figure out how many checkboxes are checked when the user clicks
>// on any one of the checkboxes.
>categoryList.click(function() {
>
>  // Figure out the number of checkboxes that are checked.
>  var checkedCount = 0;
>  categoryList.each(function() {
>if (this.checked) {
>  checkedCount++;
>}
>  }); // End of each.
>
>  // Set the heading to a different color based on how
>  // many checkboxes are checked.
>  heading.css('color', checkedCount == 0 ? 'black' : 'red');
>}); // End of click.
>
>return this;
>  }
> })(jQuery);
>


[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread Erik Beeson
But slower by 1 function call 1 time. I'd call that negligible unless you're
developing for a pocket watch.

--Erik


On Mon, Apr 6, 2009 at 5:08 PM, James  wrote:

>
> Not really. hover is theoretically just a very tad bit slower because
> internally, hover is calling mouseenter and mouseleave:
>
> hover: function(fnOver, fnOut) {
>  return this.mouseenter(fnOver).mouseleave(fnOut);
>  }
>
> On Apr 6, 1:56 pm, Nikola  wrote:
> > Is there any performance difference at all?  Say between using .hover
> > vs. binding to mouseenter and mouseleave?
> >
> > On Apr 6, 6:40 pm, James  wrote:
> >
> > > Yes, basically two different way to do the same thing.
> > > Though with bind(), you can define more than one type of events at
> > > once to the same callback.
> >
> > > .bind('mouseover mouseout blur', function(){...
> >
> > > On Apr 6, 6:53 am, jQueryAddict  wrote:
> >
> > > > I want to do something based on the click event.  I was looking at
> > > > examples and at the jQuery Docs.  Read them but so then a .blind() is
> > > > adding an event handler where .click() is obviously an event handler
> > > > but you could I guess use either or to handle for example a click
> > > > event:
> >
> > > > .bind('click', function(){...
> >
> > > > or
> >
> > > > .click(function(){
> >
> > > > right? either will work on whatever element you're working with
> > > > right?  just 2 different ways of doing the same thing in jQuery I
> > > > assume.- Hide quoted text -
> >
> > > - Show quoted text -
> >
> >
>


[jQuery] Re: jQuery.com homepage "News from the jQuery Blog" not up to date?!

2009-03-11 Thread Erik Beeson
I'm seeing this too. Quite sure it's not a cache problem on my end as I've
never visited jquery.com on this browser before.
--Erik


On Wed, Mar 11, 2009 at 2:56 PM, MarcusT  wrote:

>
> The jQuery.com homepage's  currently shows "jQuery 1.3.1
> Released" as the most recent blog post, yet if you look at the blog
> (or RSS) there have been 6 blog posts since, including the jQuery UI
> 1.7 and jQuery 1.3.2 releases!
>
> Presumably there's some server-side caching going on here and it
> hasn't updated since some time between the 22nd and 29th January.
>
> Please fix this urgently, as many people visiting jQuery.com may fail
> to realise that much has happened since then!
>


[jQuery] Re: Using jQuery.noConflict() with Prototype/Scriptaculous

2009-01-06 Thread Erik Beeson
The only thing I might guess is to do jQuery.noConflict() immediately after
loading jQuery, before loading any other scripts.
--Erik


On Tue, Jan 6, 2009 at 8:04 PM, Magnificent <
imightbewrongbutidontthin...@gmail.com> wrote:

>
> Hello all,
>
> I'm trying to incorporate jquery into pages with prototype.  This is
> what I'm doing in order:
>
> 1) Load prototype/scriptaculous
> 2) Load jquery
> 3) Execute jQuery.noConflict();
> 4) Execute jquery via (function($) { .. })(jQuery);
>
> The jquery code isn't being executed (prototype is), does anything
> look obviously wrong with what I'm doing?  I've included a mock of my
> page source below.
>
> 
> 
> 
> 
>
> http://ajax.googleapis.com/ajax/
> libs/jquery/1.2.6/jquery.min.js<http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js>
> ">
> 
>
> 
>jQuery.noConflict();
> 
> 
> 
>
> page stuff
>
> 
>//SOME PROTOTYPE STUFF
>(function() {
>//all  tags inside if a 

[jQuery] Re: Is this code legitimate?

2008-12-23 Thread Erik Beeson
Using an attribute selector to select by class isn't ideal. Maybe try:
$(':input.required')

--Erik


On Tue, Dec 23, 2008 at 5:52 PM, Rick Faircloth wrote:

>
> Is this legit?
>
> $(':input[class$="required"]')
>
> I know it'll work for a div:
>
> $('div[class$="required"]')
>
> but it doesn't seem to work to designate an input
> with a class that has "required" on the end of it's name...
>
> Rick
>
>


[jQuery] Re: if ($("#field").val() == '') or something more elegant?

2008-12-06 Thread Erik Beeson
Whoops, that matches "has no children". I think what you did is fine.
--Erik


On Sat, Dec 6, 2008 at 3:56 PM, Costaud <[EMAIL PROTECTED]> wrote:

>
> That is always saying the field is empty.
>
> On Dec 6, 5:24 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
> > Maybe try:
> > if($('#text').is(':empty'))
> >
> > --Erik
> >
> > On Sat, Dec 6, 2008 at 2:12 PM, Costaud <[EMAIL PROTECTED]> wrote:
> >
> > > Hello,
> >
> > > I'm wondering if this is the correct way of checking whether the
> > > textbox is empty or not:
> >
> > > if ($("#text").val() == '')
> >
> > > Thanks.
>


[jQuery] Re: if ($("#field").val() == '') or something more elegant?

2008-12-06 Thread Erik Beeson
Maybe try:
if($('#text').is(':empty'))

--Erik


On Sat, Dec 6, 2008 at 2:12 PM, Costaud <[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I'm wondering if this is the correct way of checking whether the
> textbox is empty or not:
>
> if ($("#text").val() == '')
>
> Thanks.


[jQuery] Re: passing 'this' into getjson callback

2008-12-05 Thread Erik Beeson
I think anonymous functions are much easier to read and understand. They
also make scoping a bit cleaner. You can rewrite with named functions if it
makes sense for your application. This is untested, but should be close to
what you're asking:

jQuery( '#myButton' ).bind( 'click', function() {var theButton = this;
jQuery.getJSON( url, null, function( json ) {
// handle json stuff here. theButton is the DOM node of the clicked
element.
// or call handleResult(json, theButton); to pass the element to
handleResult
} );});

FYI, if this is your real code, this:

jQuery.getJSON( url, null, function( json ) { myProject.handleResult( json )
} );

Is the same as this:

jQuery.getJSON( url, null, myProject.handleResult );

Creating an anonymous function that just calls a function with the same
arguments is redundant. This probably isn't actually what you want in this
case though since you then can't pass the button reference.

--Erik


On Fri, Dec 5, 2008 at 2:16 AM, pramodx <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> On click of a button I am placing a json call in the following manner
>
> jQuery( '#myButton' ).bind( 'click', myProject.callJson );
>
> The callJson function calls the json parameters:
>
> jQuery.getJSON( url, null, function( json ) { myProject.handleResult
> ( json ) } );
>
> The handleResult function further takes me to someOtherFunction() as
> well.
>
> The issue is that all the while I need to keep on passing a reference
> to the clicked button through jQuery(this) so that I can manipulate it
> in someOtherFunction(). How do I do that? Any pointers would be very
> helpful.
>
> Thanks
> Pramod
>


[jQuery] Re: document.getElementById shortcut?

2008-11-23 Thread Erik Beeson
jQuery isn't a replacement for javascript. If you want
document.getElementById, use it. If you want a shorter name, shortcut it
yourself. If you want to get the DOM node out of a jQuery object, use
$(...)[0]
--Erik

On Sun, Nov 23, 2008 at 9:34 PM, George <[EMAIL PROTECTED]> wrote:

>
> I found myself using document.getElementById often in my coding.
> Is there a shortcut for it in JQuery?
>
> PS: $('#id') is not a shortcut. Since $('#myimage').src will not work.
> $('#myimage').attr('src') will but I think that
> document.getElementById is when I do not need extensive JQuery
> selection ability.
> Plus it's
> a) faster
> b) I can always convert to JQuery collection if I need to do something
> fancy like
> var myelement = document.getElementById('myimage');
> $(myelement).hide('slow');
>
>
> PPS: so far i am thinking of creating my own $$('myimage')
>
> Thanks
> George.


[jQuery] Re: How can I return some value in jquery's callback function?

2008-11-13 Thread Erik Beeson
I'm not quite understanding you, but it seems like you need to just pass
along callback functions? Maybe you want something like:

function checkRegistered(email, doIfRegistered, doIfNotRegistered) {
var url='http://localhost/coudou/check/register.php?email=' + email;
$.getJSON(url, function(res){
   if(res.registed){
   doIfRegistered();
   }else{
   doIfNotRegistered();
   }
   });
}

Then you use it like:

checkRegistered('[EMAIL PROTECTED]', function() {
alert('Alice is registered');
}, function () {
alert('Alice is not registered.');
});

You have to use callbacks when you're dealing with asynchronous events.

Hope it helps.

--Erik


On Thu, Nov 13, 2008 at 8:17 PM, Freshow <[EMAIL PROTECTED]> wrote:

>
> Yes, it work
>
> but I want define the total as a function be called by different var
> url, and do different actions judge by true or false returned, any way
> can realize it ?
>
> On 11月14日, 上午1时41分, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > The $.getJSON callback function is not called at the time you make the
> > $.getJSON call. It's called asynchronously, much later, after the data
> has
> > been downloaded. The return value from the callback is discarded -
> there's
> > no one to return it to.
> >
> > Did you want to take two different actions depending on the value of
> > res.registed? Then do it right there in the callback. For example:
> >
> > $.getJSON(url, function(res){
> > if(res.registed){
> > doOneThing();
> > }else{
> > doAnotherThing();
> > }
> > });
> >
> > -Mike
> >
> > > -Original Message-
> > > From: jquery-en@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Freshow
> > > Sent: Thursday, November 13, 2008 7:58 AM
> > > To: jQuery (English)
> > > Subject: [jQuery] How can I return some value in jquery's
> > > callback function?
> >
> > > it didn't work when I 'return true' or 'return false', is
> > > there some way to get it?
> > > ==
> > > var 
> > > url='http://localhost/coudou/check/register.php?email='+str;
> > >$.getJSON(url, function(res){
> > >if(res.registed){
> > >return true;  // not work
> > >}else{
> > >return false; // not work
> > >}
> > >});
>


[jQuery] Re: clean jquery to halt caching

2008-11-12 Thread Erik Beeson
Maybe (untested):

if('Navigator' == navigator.appName) {
$(document).ready(function() {
$('form').each(function() {
this.reset();
});
});
}

Using $(window).load instead of $(document).ready would be truer to your
original code, but using document.ready would probably work better.

--Erik


On Wed, Nov 12, 2008 at 2:36 PM, mastorna <[EMAIL PROTECTED]> wrote:

>
> I'm patching up someone's old, and I do mean old code, and they've got
> this line of code attached to the onload handler of the body tag:
>
> onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset
> ();"
>
> This is an edge case for netscape (details below).  Is there a more
> appropriate way one would write such a thing in jQuery?
>
>
> ---
>
> Navigator Next
> Netscape Navigator recognizes a bug when using the Pragma in secure
> server situations. The site states that even if the pragma command is
> used, as long as the browser is never closed, the BACK button will
> enable someone to see the information entered.
>
> Netscape suggests that people shut down the browser after entering to
> the screen so that the BACK button doesn't have a history to scroll
> through.
>
> In addition, Netscape suggests the following JavaScript be used in the
> BODY tag of all pages that should not be cached:
>
>


[jQuery] Re: JSLitmus invaluable tool

2008-11-11 Thread Erik Beeson
With Normalize checked, I get infinity for both of them. With it unchecked,
I get 12.6M and 10.9M.
I'm using google chrome (which the test reports as Safari).

--Erik

On Tue, Nov 11, 2008 at 9:16 AM, howardk <[EMAIL PROTECTED]> wrote:

>
> I've been experimenting with several different coding styles for plug-
> ins. Lately I've been curious about the difference in performance
> between using local variables vs. instance variables for storing
> state. JSLitmus, while not itself jQuery-based, has just given me the
> answers I've been looking for. I found them a bit surprising:
>
> http://www.fatdog.com/litmus_tests/InstanceVsLocalTest.html
>
> (Apologies for the color scheme! :-)
> Howard
>


[jQuery] Re: unsubscribe

2008-11-03 Thread Erik Beeson
http://www.google.com/search?q=google+groups+unsubscribe

On Mon, Nov 3, 2008 at 9:59 AM, Minal Patki <[EMAIL PROTECTED]> wrote:

> I do not wish to recieve any emails from this group.
> Thanks
>
>


[jQuery] Re: how change external html AFTER load using $.load

2008-10-22 Thread Erik Beeson
Perhaps you want the livequery plugin?
http://brandonaaron.net/docs/livequery/

--Erik


On Wed, Oct 22, 2008 at 5:36 PM, gtso86 <[EMAIL PROTECTED]> wrote:

>
> I create a simple test like my problem... because my real problem
> hosted on blocked domain for external visits.
>
> http://www.gabrieltadeu.com/teste/testes.html
>
> this example above have the same problem. i need the function
>
>$('#rapida ul a').click(function () {
> var url = $(this).attr('title');
>alert(url);
>});
>
>
> work with the loaded content.
>
> for repeat my probleam:
>
> click in 'MG' (this action fire the load content)
>
> now, click in 'Belo Horizonte' (this is the load content!) first alert
> dont appear. :(
>
>
>
> On 22 out, 21:59, "Jonathan Sharp, Out West Media"  [EMAIL PROTECTED]> wrote:
> > Hi gtso86,
> >
> > Do you have a URL of the page in question?
> >
> > It may be that you need to call your $('#rapida ul a')... code after
> > $.load() is finished loading the content.
> >
> > You could do this by using the callback argument:
> > $.load(url, [data], function() {
> > $('#rapida ul a')...
> >
> > });
> >
> > Cheers,
> > -Jonathan
> >
> > On Oct 22, 2008, at 5:32 PM, gtso86 wrote:
> >
> > > Hi everybody... this morning i started a project $.load. When i load
> > > the html using $load in the main page (default.aspx) i cant interacte
> > > with using jQuery.
> >
> > > Simple interactives like
> >
> > > $('#rapida ul a').click(function () {
> > >var url = $(this).attr('href');
> > >alert(url);
> > >//$(this).parents().css('border','1px solid red');
> > > });
> >
> > > dont work ONLY in the loaded content. i can manipulate this content?
>


[jQuery] Re: Help optimising jquery code - there must be a better way

2008-10-21 Thread Erik Beeson
I don't have time to rewrite your whole example, but I can offer a few tips
that might help. Selecting by class alone can be pretty slow. Basically
every single tag has to be checked for the class every time you do a
selection by class. It would help to at least give the HTML tag that the
class is being applied to, like $('li.current_page_item').
You do quite a few next/prev/addClass calls on the same elements, but you're
reselecting them every time. I suggest you use the "end" function.
Operations that modify what elements are selected work as a stack, and allow
you to "undo" operations, like so:

$(".current_page_item").next().addClass('after').end().prev().addClass('before');
$(".current_page_ancestor").next().addClass('after').end().prev().addClass('before');

Calls to the $ function are often expensive, so it can help to cache them in
a local variable if you find you're calling $ with the same parameter
multiple times.

For that repetitive stuff you're doing at the end, I suggest you look into
the "each" function.

Hope it helps.

--Erik


On Mon, Oct 20, 2008 at 8:08 PM, Kent Humphrey <[EMAIL PROTECTED]>wrote:

>
>
> I am relatively new to jquery, but have managed to muddle my way through a
> complicated navigation design that has overlapping selected states, eg with
> menu items 1,2,3,4 and 5, when item 2 is selected, the images for items 1
> and 3 also have to change.
>
>
> The code is long and convoluted, and I am sure there is a cleaner way to do
> what I am doing. If anyone has any ideas, that would be great.
>
>
> Here's the code:
>
>
>
> // setup before and after classes
> $(".current_page_item").next().addClass('after');
> $(".current_page_item").prev().addClass('before');
> $(".current_page_ancestor").next().addClass('after');
> $(".current_page_ancestor").prev().addClass('before');
>
> // do overlapping images
> $("#primary_nav a").hover(
>function() {
>
>if ((!$(this).parent().hasClass('current_page_ancestor')) &&
> (!$(this).parent().hasClass('current_page_item'))) {
>$(".current_page_item").next().removeClass('after');
>
>  $(".current_page_item").prev().removeClass('before');
>
>  $(".current_page_item").addClass("current_disabled");
>
>  $(".current_page_ancestor").next().removeClass('after');
>
>  $(".current_page_ancestor").prev().removeClass('before');
>
>  $(".current_page_ancestor").addClass("current_disabled");
>}
>},
>function() {
>$(".current_disabled").next().addClass('after');
>$(".current_disabled").prev().addClass('before');
>$(".current_disabled").removeClass("current_disabled");
>}
> );
>
> $("#page_item_2 a").hover(
>function() {
>$("#page_item_5").addClass('after');
>},
>function() {
>if (!$(this).parent().hasClass('current_page_item')) {
>$("#page_item_5").removeClass('after');
>}
>}
> );
>
> $("#page_item_5 a").hover(
>function() {
>$("#page_item_2").addClass('before');
>$("#page_item_7").addClass('after');
>},
>function () {
>if ((!$(this).parent().hasClass('current_page_ancestor')) &&
> (!$(this).parent().hasClass('current_page_item'))) {
>$("#page_item_2").removeClass('before');
>$("#page_item_7").removeClass('after');
>}
>}
> );
>
> $("#page_item_7 a").hover(
>function() {
>$("#page_item_5").addClass('before');
>$("#page_item_9").addClass('after');
>},
>function () {
>if (!$(this).parent().hasClass('current_page_item')) {
>$("#page_item_5").removeClass('before');
>$("#page_item_9").removeClass('after');
>}
>}
> );
>
> $("#page_item_9 a").hover(
>function() {
>$("#page_item_7").addClass('before');
>$("#page_item_11").addClass('after');
>},
>function () {
>if (!$(this).parent().hasClass('current_page_item')) {
>$("#page_item_7").removeClass('before');
>$("#page_item_11").removeClass('after');
>}
>}
> );
>
> $("#page_item_11 a").hover(
>function() {
>$("#page_item_9").addClass('before');
>},
>function () {
>if (!$(this).parent().hasClass('current_page_item')) {
>$("#page_item_9").removeClass('before');
>}
>}
> );
>
>
> By way of explanation, this is using the css sprites method where I have a
> single image that is all the different states of the nav. The 'before' and
> 'after' classes are used to indicate the nav items either side of the
> selected item. 'current_page_item' and 'current_page_ancestor' are

[jQuery] Re: id same as name confuses JQuery?

2008-10-13 Thread Erik Beeson
I assume your use of braces instead of parenthesis is just a typo?

I am unable to reproduce this. This works for me:

$('body').append('...');
$('#foobar').size();   // 1

Could you provide a sample page?

--Erik


On Mon, Oct 13, 2008 at 1:30 PM, Tim Scott <[EMAIL PROTECTED]> wrote:

>
> Given this element...
>
>
>
> ...why this does not match the element...
>
>${'#foo'}
>
> If I change or remove the name attribute, it does match.  Is this by
> design or a bug?
>


[jQuery] Re: Animate backgroundColor?

2008-10-10 Thread Erik Beeson
A google search for jquery animate color will lead you to the color plugin,
which will do what you want.

--Erik


On Thu, Oct 9, 2008 at 9:43 PM, Jimbo M <[EMAIL PROTECTED]> wrote:

>
> I'm fresh and green to jQuery and enjoying it immensely.  One thing
> I'm used to doing in AJAX is to animate a background-color across a
> range specified like #fff -> #000
>
> When I try doing this using $('#Panel').animate({ backgroundColor:
> #000}, 1000) I get an error because it doesn't seem to know where to
> start, even though I'm using CSS to set the background-color to #fff.
>
> Is there a way to animate across a color range that I'm missing?
>
> This whole jQuery so ROCKS!  If I have to learn ANYTHING new this
> coming month, it's gonna be jQuery!
>
> --- Jim ---
>


[jQuery] Re: OT : javascript editor (with code formatting)

2008-10-07 Thread Erik Beeson
Not free, and probably not what you're looking for, but I can't recommend
IntelliJ IDEA enough. Among a lot of other things, it has great JavaScript
support with syntax highlighting, refactoring, code completion, and
reformatting.

--Erik


On Tue, Oct 7, 2008 at 8:13 AM, Alexandre Plennevaux
<[EMAIL PROTECTED]>wrote:

> Friends,
>
> aptana studio, albeit a nice editor, is recently crashing all the time and
> now doesn't even want to restart. I'm looking for a good alternative, that
> has a code formatting (auto indenting) functionality.
>
> Any suggestion ? I'm on Windows XP SP3...
>
> Thank you,
>
>
> Alexandre
>


[jQuery] Re: Possible to set metadata parameter dynamically?

2008-10-06 Thread Erik Beeson
In an older version of the metadata plugin, you used to be able to set
something (metaDone to false I think it was) that would force it to reload,
but that doesn't work anymore.

This is all untested, but here's my read on it:

Now, metadata is stored in jQuery's internal caching system, which
associates arbitrary data with DOM elements. To remove all metadata for a
particular element use:

$.removeData(element, 'metadata');

The removeData function is described here:

http://docs.jquery.com/Internals/jQuery.removeData#elemname

To force one or more elements from a jQuery selection to refresh, try:

$(...).each(function() { $.removeData(this, 'metadata'); });

Hope it helps.

--Erik

P.S.: If you're changing the 'single' option like $(...).metadata({single:
'foo'})..., you need to use the same value for the second parameter to
removeData ('foo', in this case).


On Sat, Oct 4, 2008 at 1:24 PM, me-and-jQuery <[EMAIL PROTECTED]>wrote:

>
> So is it possible to change the value of metadata parameter? Lets say
> we have .
>
> Or is the only way to change it with attr("id","6")? I have more
> parameters for element, so this is not an elegant solution.
>
>
> Thanks.
>


[jQuery] Re: XML Parsing Question...

2008-10-06 Thread Erik Beeson
To my knowledge, XML parsing via the jQuery constructor isn't supported.

See here: http://dev.jquery.com/ticket/3143

--Erik


On Sat, Oct 4, 2008 at 12:29 PM, KenLG <[EMAIL PROTECTED]> wrote:

>
> For much of my app, I'm doing an Ajax hit to the server to grab XML.
> That works great.
>
> But, in some cases, I've got too many pieces of data (unrelated) that
> I need to pull so I'm trying to do a simple passthrough from the
> server side (I'm using ASP.Net). So, I'll either output from SQL
> Server or hand-stitch some XML and write it to the page.
>
> Whenever I do this passthrough (whether it comes from SQL Server or
> from my own efforts), the XML doesn't get parsed by Jquery.
>
> For example:
>
> var sTestXML = '\r
> \nHello EventContactData>\r\n';
>
> var test = $(sTestXML);
>
> alert(test.find("EventContact").length);
>
> will result in the alert showing zero.
>
> Now, if I lower case some of the tags (and this will vary from XML doc
> to XML doc but usually it's the root and object-level tags), it'll
> work. What's going on here?
>


[jQuery] Re: There must be a better way to write this

2008-10-01 Thread Erik Beeson
How about a self calling anonymous function:

$('#folio > :first').fadeOut(function() {
$(this).next().fadeOut(arguments.callee); });
Or if you're uncomfortable with that syntax, just make a function for it:

function fadeNext() {
$(this).next().fadeOut(fadeNext);
}

$('#folio > :first').fadeOut(fadeNext);

--Erik

On Wed, Oct 1, 2008 at 2:36 PM, ferdjuan <[EMAIL PROTECTED]> wrote:

>
> I'm trying to fade an element out, then fade it's next sibling out,
> with no predetermined amount of elements. Here is an example of how I
> have it now but with only 3 elements:
>
> function fadeEmOut(){
>var kid = $('#folio').children();
>kid.eq(0).fadeOut(function(){
>kid.eq(1).fadeOut(function(){
>kid.eq(2).fadeOut();
>});
>});
> }
>
> i KNOW there is a better way to write this, I attempted using the
> each() function but it fades every element simultaneously. When
> someone writes back with the answer I'm gonna feel like a tard. Thanks!
>


[jQuery] Re: unsubscribe

2008-10-01 Thread Erik Beeson
Perhaps you're looking for:
http://groups.google.com/group/jquery-en/subscribe

--Erik

On Wed, Oct 1, 2008 at 4:18 PM, Steve Schnable <[EMAIL PROTECTED]> wrote:

> unsubscribe!
>


[jQuery] Re: XHTML Selector Nightmare

2008-10-01 Thread Erik Beeson
Try this:

$('.sMarker ~ row', myTable).not($('.eMarker ~ row', myTable))

That will get what you want, but I think it won't include the .sMarker row.
To get .sMarker also, maybe try:

 $('.sMarker,.sMarker ~ row', myTable).not($('.eMarker ~ row', myTable))

You can also do it by index without each() like this:

var $rows = $('row', myTable);
var $range = $rows.slice($rows.index($rows.filter('.sMarker')),
$rows.index($rows.filter('.eMarker'))+1);

Hope it helps.

--Erik


On Wed, Oct 1, 2008 at 11:31 AM, greenteam003 <[EMAIL PROTECTED]> wrote:

>
>
> I really don't know why I'm having such a hard time with this (maybe its
> the
> two monsters and three cups of coffee) but I'm trying to select a range of
> rows in a 1000 row xhtml table, between starting row with class "sMarker"
> and ending row with class "eMarker".  I'm trying to use the following
> selector...
>
> $('.sMarker ~ row:not(".eMarker ~ row")',myTable)
>
> In my mind this should take my ".sMarker" row, grab all sibling rows after,
> and then filter out any rows that come after my ".eMarker" row.  Or am I
> just overthinking this?
>
> Currently that selector will select ALL rows after my ".sMarker" excluding
> the single row marked with ".eMarker".
>
> Note:  To filter out any responses that are blindingly obvious, the table
> row tags in my xhtml are really "row" not tr.
>
> I don't know how else to get this "between" functionality without using
> indexes and the each iteration is a huge performance loss when dealing with
> larger tables.
>
> Please help because I can not wrap my head around this one this morning.
>
> Thanks,
> greenteam
>
>
>
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/XHTML-Selector-Nightmare-tp19766491s27240p19766491.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>


[jQuery] Re: Metadata parameter as selector

2008-09-29 Thread Erik Beeson
The previous responses don't seem to get that you're using the metadata
plugin. I would suggest using filter:

$('tr').filter(function() { return $(this).metadata().id == 4; })...

If you find yourself doing that a lot, you can add a custom selector
for metadata. Something like:

jQuery.extend(jQuery.expr[':'], {
 meta:
"!m[3]||((p=m[3].split('='))&&(p.length>1?$(a).metadata()[p[0]]==p[1]:$(a).metadata()[p[0]]))"
});
Which you could then use like:
$('tr:meta(id=4)')...

I put together a little test page:

http://erikandcolleen.com/erik/projects/jquery/metaselector/

Seems to work in IE7 and FF3. Untested elsewhere.

Hope it helps.

--Erik


On Mon, Sep 29, 2008 at 10:23 AM, me-and-jQuery <[EMAIL PROTECTED]>wrote:

>
> I am searching the web and documentation and still can't find a
> working solution.
>
> I have a table which rows has also id with metadata, for example  data="{id:4}">
>
> And now I want to select row with id 4. I was trying many ways but no
> success for now. For example:
>
> $.metadata.setType("attr", "data")
> $("table tr.id:4").metadata().remove();
>
>
> Anyway, is this possible with metadata at all? Thanks for any help.
>


[jQuery] Re: Insert variable into a selector

2008-09-22 Thread Erik Beeson
According to the docs, 'this' within a success callback is the "options"
object, so 'this.id' doesn't mean anything useful:
http://docs.jquery.com/Ajax/jQuery.ajax#options

Also, $(this.id) probably isn't anything useful either.

Maybe try this (untested):

$('.makeFavorite').click(function() {
   var id = this.id;
   $.ajax({
   type: "POST",
   url: "make_favorite.php",
   data: "id=" + id,
   success: function(msg) {
   alert('Data saved: ' + msg);
   $('#' + id + ' img').attr({src :
"images/"+msg+".png"});
   }
   });
   return false;
});

Hope it helps.

--Erik



On Mon, Sep 22, 2008 at 1:16 AM, suntrop <[EMAIL PROTECTED]> wrote:

>
> This is the JS code:
> $('.makeFavorite').click(function() {
>$.ajax({
>type: "POST",
>url: "make_favorite.php",
>data: "id=" + $(this.id),
>success: function(msg) {
>alert('Data saved: ' + msg);
> $('h1 a#' + this.id + ' img').attr({src :
> "images/"+msg+".png"});
>}
> });
>return false;
> });
> The HTML code:
> {$ent.firma}  id="{$ent.id}" title="Save favorite"> alt="" />
>
> Both variables don't do what what I expect them to do. The first
> doesn't find the correct target/id and the seccond doesn't insert the
> image correctly. But if I write down the id and the true path it works
> fine.
>
> What do I have to change?
>
> On 22 Sep., 05:42, ricardobeat <[EMAIL PROTECTED]> wrote:
> > I can't get it either, what are you trying to accomplish?
> >
> > $('h1 a#' + this.id') is not logical, you first need to reference some
> >  element to get it's ID, but in doing that you already wrote the
> > ID...
> >
> > On Sep 21, 11:16 pm, FrenchiINLA <[EMAIL PROTECTED]> wrote:
> >
> > > i think your problem is this.id, you have to show the entire code in
> > > order for us to see what does this mean. try just to add a alert for
> > > example to see what you get for this.id
> >
> > > On Sep 21, 7:38 am, suntrop <[EMAIL PROTECTED]> wrote:
> >
> > > > HI there,
> >
> > > > I want to insert two variables into the selector and an attribute.
> But
> > > > it doesn't work.
> >
> > > > $('h1 a#' + this.id + ' img').attr({src : "images/" + msg +
> ".png"});
> >
> > > > I looked through various tutorials but couldn't find an answer to
> > > > this.
> >
> > > > The first variable comes from the object's ( element) id and the
> > > > seccond is a response from an php script.
> >
> > > > Can somebody please help me?
>


[jQuery] Re: Case Insentitive Selectorys

2008-09-22 Thread Erik Beeson
Maybe try using filter and a regexp for the part that you want to be case
insensitive. Something like (very untested):
$(...).find('item').filter(function() { return this.name.match(new
RegExp(search, 'i')); }).each(function() {

});

I don't recall the syntax for accessing an XML attribute from javascript, so
the "this.name" part might be wrong. Maybe you need $(this).attr('name')
instead. Also, you might want to be doing more than just passing the search
into a RegExp, but you get the idea.

Also, maybe reconsider what you're trying to do. Maybe just return your xml
such that it's already been converted to lower case, then just do what you
were doing before except use search.toLowerCase() instead of just search.

Hope it helps.

--Erik



On Mon, Sep 22, 2008 at 12:35 AM, blockedmind <[EMAIL PROTECTED]> wrote:

>
> Nothing?
>
> On Sep 20, 5:22 pm, blockedmind <[EMAIL PROTECTED]> wrote:
> > I am making search in an xml file, but I don't get expected results
> > since jQuery selectors arecase-sensitive. I use something like
> >
> > $(returnedXml).find("item[name*='"+search+"']").each(function(){
> >
> > });
> >
> > How to make it INCASE-SENSITIVE?
>


[jQuery] Re: Anyone know where to ask jQuery questions?

2008-09-05 Thread Erik Beeson
It's only been 4 hours since your original thread. Seems awfully quick to
already be complaining about a lack of response.

I looked at your thread and had no idea why XML parsing wouldn't work. I
guess I had never come across that before. I didn't respond because I didn't
know, and I didn't look at your page because you summed up the problem in
your email.

It's a high traffic list, so I can't imagine everyone looks at every thread.
In the future I suggest you try to use a more meaningful subject, such as
"Trouble with .each() on XML". Someone who knew about it just skimming might
have recognized that and been able to help you (like Jake ultimately did).

In terms of other places to get help, the docs are a pretty good, and might
have help you in this case as they make no representation that XML parsing
from strings works with the jQuery constructor. Also, the IRC channel can be
very helpful, as can Google.

Good luck.

--Erik



On Fri, Sep 5, 2008 at 11:53 AM, Jim Buzbee <[EMAIL PROTECTED]> wrote:

>
> I must be in the wrong group. This morning, I posted a question ("I
> must be missing something simple...") on a pared-down jQuery code
> segment and a URL showing the problem. Out of the 10,000+ members of
> the mailing list, my Apache log shows a grand total of 1 hit on the
> example and I got no response on the mailing list.
>
> I must be in the wrong list. Is there somewhere to ask jQuery
> questions?
>
> Once again, the code in question can be found at:
>
> http://batbox.org/bh.html
>
> It works under firefox/safari, and doesn't under IE7
>
> Thanks,
> Jim Buzbee
>


[jQuery] Coverflow

2008-09-04 Thread Erik Beeson
No association with jQuery, but here's a nice JavaScript coverflow effect
that I thought people might like:
http://radnan.public.iastate.edu/coverflow/

It mucks around with extending builtin objects, which is bad form to us
jQuerians, but it's a nice effect.

--Erik


[jQuery] Re: New Google Browser announced

2008-09-04 Thread Erik Beeson
>
> However, as Google mentions themselves, if your website is compatible with
> Safari 3 it should autmatically also be compatible with the current Chrome
> version.
>

Sort of. It's not an issues of a new renderer to support (WebKit, same as
Safari/Android), it's an issue of a new JavaScript engine to support (V8),
which is a real concern as the jQuery test suite apparently fails a couple
of tests on Chrome.

--Erik


[jQuery] Re: Cross domain problems

2008-07-24 Thread Erik Beeson

The problem arises when you're on http://username.example.com/ and you
want to make an ajax request to http://example.com/ or you're on
http://example.com and you want to make a ajax request to
http://ajax.example.com/

You'll have cross-domain issues since the domains aren't the same. But
since your SLD is the same, you can set document.domain to
'example.com' and everything will play nice.

If you make your ajax requests to the same server that served up the
page that you're on, then this isn't an issue as you can just us an
absolute URI, as you suggested. But such isn't always the case,
especially on larger sites.

--Erik


On 7/10/08, Vincent Robert <[EMAIL PROTECTED]> wrote:
>
>  I may be misunderstading something here but this does not look like a
>  cross-domain issue to me.
>
>  If you are making AJAX request on the same server that served the
>  page, then you should use absolute URI path without any protocol nor
>  domain name : $.get("/some/web/service"). This will work whatever
>  domain your user typed in his browser (www.example.com or
>  example.com).
>
>  If you are really making a cross-domain AJAX call, meaning that you
>  are calling another server (like yahoo.com or google.com) then
>  browsers will prevent you from doing that and you should rely on a
>  proxy webservice that you must create on your server.
>
>  Have I missed something obvious?
>
>
>
>  On Jul 10, 4:07 am, flycast <[EMAIL PROTECTED]> wrote:
>  > I have determined that the error was from a different script. Sorry
>  > about the confusion.
>  >
>  > After working on the document.domain I could not get it to work/help.
>  > The load statement would just not return any result.
>  >
>  > The solution that Jeffery offered above worked like a champ.
>  >
>  > Thanks for all your help.
>  >
>  > On Jul 9, 11:56 am, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>  >
>  > > I had this same problem, which I solved by parsing the 
> window.location.href
>  > > prior to making the ajax call, based on the current host used to access 
> the
>  > > site.
>  >
>  > > var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] +
>  > > '/pathtomyresource';
>  >
>  > > JK
>  >
>  > > -Original Message-
>  > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>  >
>  > > Behalf Of Erik Beeson
>  > > Sent: Wednesday, July 09, 2008 9:33 AM
>  > > To: jquery-en@googlegroups.com
>  > > Subject: [jQuery] Re: Cross domain problems
>  >
>  > > The protocol *must* be the same (if the page ishttps://.../thenthe
>  > > ajax request must also be tohttps://.../).
>  >
>  > > The port *must* be the same.
>  >
>  > > The host name *must* have the same SLD [1], and if the subdomains are
>  > > different, document.domain *must* be set to the SLD.
>  >
>  > > I'm certain that this can work as I do it all the time. If you're
>  > > still having trouble, could you create a page that demonstrates the
>  > > problem?
>  >
>  > > --Erik
>  >
>  > > [1]http://en.wikipedia.org/wiki/Second-level_domain
>  >
>  > > On 7/9/08,flycast<[EMAIL PROTECTED]> wrote:
>  >
>  > > >  I tried setting document.domain = 'site.com';
>  > > >  It works with a domain of site.com but notwww.site.com. I now get the
>  > > >  following message:
>  >
>  > > >  [Exception... "'Permission denied to call method XMLHttpRequest.open'
>  > > >  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>  > > >  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
>  > > >  data: no]
>  >
>  > > >  This seems to be a different problem.
>  >
>  > > >  BTW...here is a Mozilla link to the issue of cross domain and the use
>  > > >  of 
> document.domain:http://www.mozilla.org/projects/security/components/same-origin.html
>  >
>  > > >  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>  > > >  > Well, I thought this is security browser issue.
>  >
>  > > >  > I always solve this problem this way:
>  > > >  > Eg.:
>  >
>  > > >  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>  >
>  > > > > I create
>  > > 
> this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c..
>  > > .
>  

[jQuery] Re: Sending a JSON object as data in an AJAX request

2008-07-16 Thread Erik Beeson
HTTP parameters are key/value pairs. If you have an object like:

var json = {
  foo: 'bar',
  boo: 'far'
};

It will get converted into HTTP parameters foo=bar and boo=far.

In your example, you have one key, "Request", and its value is an object.
Converting the value (a JavaScript object) to a string yields "[object
Object]", which is what you're seeing. If you were expecting to get complex
PHP objects on your server side, you're mistaken about how HTTP parameters
work :)

Basically, make your JSON object only one level deep and you should be fine.

Hope it helps.

--Erik


On 7/15/08, jlb <[EMAIL PROTECTED]> wrote:
>
>
> According to the jQuery docs, the data option (in $.ajax) is supposed
> to accept a string or an object (which it then converts to a query
> string).  It appears as though its not converting my object:
>
>
> My Javascript is:
>
> var json = {
>   "Request" : {
>   "action" : "doSomething",
>   "params"   : {"id":"123"}
>   }
>};
>
> $.ajax({
> type: "POST",
> url: WEB_DOMAIN + "/api.php",
> data: json
> });
>
> In api.php contains:
>
>   
>
> Which outputs:
>
> string(15) "[object Object]"
>
>
> Does anyone know what I'm doing wrong?
>


[jQuery] Re: array method on a jQuery object: deleting, adding elements

2008-07-12 Thread Erik Beeson

Check out the functions here, particularly under Filtering:

http://docs.jquery.com/Traversing

--Erik


On 7/12/08, wolf <[EMAIL PROTECTED]> wrote:
>
>
>  hi all,
>
>  since a jQuery collection (say, `var j = $( 'div' )`) looks and
>  behaves a bit like a standard javascript array (you can iterate over
>  it, fetch single elements using `j[n]`, delete everything doing
>  `j.length = 0`), what is the preferred way to do other array-like
>  manipulations on it?
>
>  let's say i have `j` as defined above, and want to throw out (from the
>  collection, not from the document) any element that the user clicks
>  on, how could i do that? i browsed parts of the source but did not
>  grok where a jQuery object keeps its collection of elements (my own
>  javascript code looks like cave painting in comparison). am i missing
>  something terribly obvious here?
>
>
>  _wolf
>

heckc out the stuff under filtering:


[jQuery] Re: Cross domain problems

2008-07-09 Thread Erik Beeson

The protocol *must* be the same (if the page is https://.../ then the
ajax request must also be to https://.../).

The port *must* be the same.

The host name *must* have the same SLD [1], and if the subdomains are
different, document.domain *must* be set to the SLD.

I'm certain that this can work as I do it all the time. If you're
still having trouble, could you create a page that demonstrates the
problem?

--Erik

[1] http://en.wikipedia.org/wiki/Second-level_domain


On 7/9/08, flycast <[EMAIL PROTECTED]> wrote:
>
>  I tried setting document.domain = 'site.com';
>  It works with a domain of site.com but not www.site.com. I now get the
>  following message:
>
>  [Exception... "'Permission denied to call method XMLHttpRequest.open'
>  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
>  data: no]
>
>  This seems to be a different problem.
>
>  BTW...here is a Mozilla link to the issue of cross domain and the use
>  of document.domain: 
> http://www.mozilla.org/projects/security/components/same-origin.html
>
>
>
>
>  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>  > Well, I thought this is security browser issue.
>  >
>  > I always solve this problem this way:
>  > Eg.:
>  >
>  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>  >
>
> > I create 
> > this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c...
>  >
>  > --
>  > Alexsandrowww.alexsandro.com.br
>
> >
>  > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>  >
>  > > Add this somewhere in your javascript:
>  >
>  > > document.domain = 'site.com';
>  >
>  > > Google document domain
>  >
>  > > --Erik
>  >
>  > > On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>  >
>  > > >  Simple problem (I think)...
>  >
>  > > >  I am new to JS and ajax.
>  >
>  > > >  I am building an ajax capability on a clients site. I am running into
>  > > >  cross domain problems. If I get the page using the url 
> formhttp://www.site.com
>  > > >  but I do a load using the url form "http://site.com"; (www vs. no www
>  > > >  in the url) I get nothing but a js error.
>  >
>  > > >  What is the best way to handle making sure that if the person is at
>  > > >  the site with OR without the "www" in the url that the .load will
>  > > >  still work?
>


[jQuery] Re: Cross domain problems

2008-07-08 Thread Erik Beeson

Add this somewhere in your javascript:

document.domain = 'site.com';

Google document domain

--Erik


On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>
>  Simple problem (I think)...
>
>  I am new to JS and ajax.
>
>  I am building an ajax capability on a clients site. I am running into
>  cross domain problems. If I get the page using the url form 
> http://www.site.com
>  but I do a load using the url form "http://site.com"; (www vs. no www
>  in the url) I get nothing but a js error.
>
>  What is the best way to handle making sure that if the person is at
>  the site with OR without the "www" in the url that the .load will
>  still work?
>


[jQuery] Re: Need truncator/Expander help (trimming on # of objects rather than character count)

2008-07-06 Thread Erik Beeson

Seems to have some HTML escaping issues on your options page:
http://plugins.learningjquery.com/summarize/index.html#options

At least in Safari.

--Erik


On 7/6/08, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>
>  sorry, but I'm changing the name from summarizer (with an r) to summarize.
> Seems to make more sense as a verb. so now you can find it at:
>
>  http://plugins.learningjquery.com/summarize/
>
>  --Karl
>  
>  Karl Swedberg
>  www.englishrules.com
>  www.learningjquery.com
>
>
>
>
>  On Jul 6, 2008, at 3:22 PM, Karl Swedberg wrote:
>
>
> >
> > sounds like a reasonable thing to want, so I just whipped up a new plugin
> for you:
> >
> > http://plugins.learningjquery.com/summarizer/
> >
> > Please keep in mind that it hasn't been tested extensively, and the
> documentation is kind of spotty, but it shouldn't be too hard to figure out
> how it works.
> >
> > One important thing to note is that your selector should be the parent
> element of the elements you want to expand/collapse.
> >
> > --Karl
> > 
> > Karl Swedberg
> > www.englishrules.com
> > www.learningjquery.com
> >
> >
> >
> >
> > On Jul 6, 2008, at 11:55 AM, clorentzen wrote:
> >
> >
> > >
> > > I am looking to add an expander/truncator feature to a site I'm
> > > building. However, the plugins and other code snippets I've found cut
> > > off text based on character count. What I'm looking for is something
> > > that cuts off based on a specific number of paragraphs. So, for
> > > example, inside a targeted div, after the second  it would hide all
> > > remaining s, and insert a "read more" link. Clicking would expose
> > > the hidden elements and add a "read less" link.
> > >
> > > I haven't been able to figure out a way to do this... Can anyone point
> > > me in the right direction? I've posted an example page here:
> > >
> > > http://www.cement-site.com/truncator/example.shtml
> > >
> > > It's making use of the truncator plugin found here:
> > > http://henrik.nyh.se/2008/02/jquery-html-truncate
> > >
> > > (I've also tried Karl Swedberg's Expander plugin, but it doesn't seem
> > > appropriate in this case since it's not intended to truncate/expand
> > > across multiple block-level elements.)
> > >
> > > Can this truncator plugin code be modified to count s rather than
> > > characters? Or is there a simpler/better way to accomplish this?
> > >
> > > Thanks!
> > >
> >
> >
>
>


[jQuery] Re: Why (function($){ ...})(jQuery) instead of (function(){var $ = jQuery; ...})()?

2008-07-04 Thread Erik Beeson
On Fri, Jul 4, 2008 at 7:29 AM, Ariel Flesler <[EMAIL PROTECTED]> wrote:

> Note that the
>  (function($){ ... })(jQuery);
> approach is 6 bytes shorter than
>  (function(){ var $ = jQuery; })();
>
> It also looks cooler ;)
>

These were exactly the points I was going to make. Since $ is really a
utility function, having a variable declaration for it all the time seems
ugly. The closure trick feels much cleaner, and nicely separates my local
variables from the $ function.

Plus it's shorter.

--Erik


[jQuery] Re: Position cursor at end of textbox?

2008-07-02 Thread Erik Beeson
No worries. Thanks for taking the time to test it :) Scoping is probably one
of the most unobvious aspects of JavaScript.

--Erik


On 7/2/08, Brian J. Fink <[EMAIL PROTECTED]> wrote:
>
>
> My apologies, Erik. Yours is the superior method. I must have been
> remembering the behavior of IE5.
>
>
> On Jul 2, 8:12 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>
> > Ick! Global variables and eval'd code! How about (untested, logic should
> be
> > unchanged):
> >
> > $(function() {
> > $(':text').bind('focus', function() {
> > var o = this;
> > if(o.setSelectionRange) { /* DOM */
> > setTimeout(function()
> > {o.setSelectionRange(o.value.length,o.value.length);}, 2);
> > } else if(o.createTextRange) {/* IE */
> > var r = o.createTextRange();
> > r.moveStart('character', o.value.length);
> > r.select();
> > }
> > });
> >
> > });
> >
> > Adds an anonymous function, which adds a function call, but saves an eval
> > and doesn't require a global variable, which is potentially problematic.
> >
> > --Erik
> >
>
> > On 7/2/08, Brian J. Fink <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > And I checked my code again. It DOES work on FF3, FF2, and IE7.
> >
> > > On Jul 2, 5:37 pm, Paul Malan <[EMAIL PROTECTED]> wrote:
> > > > Thanks for the code.  It doesn't work for me--still when I tab into a
> > > > textbox in either IE7 or FF3 the content is selected and the cursor
> > > > isn't positioned at the end of the text, even when I pull out
> > > > everything but this function and two textboxes to test.
> >
> > > > I think I may just give up--it was a minor detail and not requested
> by
> > > > the users.  Bugs me, though.  Seems like it shouldn't be so
> tricksy...
> >
> > > > On Jul 2, 3:12 pm, "Brian J. Fink" <[EMAIL PROTECTED]> wrote:
> >
> > > > > There may be a jQuery way to do this, but I don't know what it is.
> >
> > > > > However, I do know 2 ways to accomplish this: one DOM way, one IE
> way.
> > > > > Both methods must be employed.
> >
> > > > > $(function() {
> > > > >  $('input[type="text"]').bind('focus',function() {
> > > > >   window.o=this;
> > > > >   if (o.setSelectionRange) /* DOM */
> > > >
> >setTimeout('o.setSelectionRange(o.value.length,o.value.length)',2);
> > > > >   else if (o.createTextRange) /* IE */
> > > > >   {
> > > > >var r=o.createTextRange();
> > > > >r.moveStart('character',o.value.length);
> > > > >r.select();
> > > > >   }
> > > > >  });
> >
> > > > > });
> >
> > > > > On Jul 2, 2:55 pm, Paul Malan <[EMAIL PROTECTED]> wrote:
> >
> > > > > > By default it seems browsers select all the text in a textbox
> when it
> > > > > > gains focus by way of a tab-press.  I would like the cursor to be
> > > > > > positioned at the end of any existing text in the input,
> > > instead.  The
> > > > > > examples I'm turning up on Google don't work and seem needlessly
> > > > > > complex, and since jQuery simplifies everything else I used to
> hate
> > > > > > about Javascript, I thought I'd see if there's a simple way to
> > > > > > position the cursor in a text input box on focus.  Is it doable?
> >
> > > > > > Thanks...
>


[jQuery] Re: Position cursor at end of textbox?

2008-07-02 Thread Erik Beeson
Ick! Global variables and eval'd code! How about (untested, logic should be
unchanged):

$(function() {
$(':text').bind('focus', function() {
var o = this;
if(o.setSelectionRange) { /* DOM */
setTimeout(function()
{o.setSelectionRange(o.value.length,o.value.length);}, 2);
} else if(o.createTextRange) {/* IE */
var r = o.createTextRange();
r.moveStart('character', o.value.length);
r.select();
}
});
});

Adds an anonymous function, which adds a function call, but saves an eval
and doesn't require a global variable, which is potentially problematic.

--Erik



On 7/2/08, Brian J. Fink <[EMAIL PROTECTED]> wrote:
>
>
> And I checked my code again. It DOES work on FF3, FF2, and IE7.
>
>
> On Jul 2, 5:37 pm, Paul Malan <[EMAIL PROTECTED]> wrote:
> > Thanks for the code.  It doesn't work for me--still when I tab into a
> > textbox in either IE7 or FF3 the content is selected and the cursor
> > isn't positioned at the end of the text, even when I pull out
> > everything but this function and two textboxes to test.
> >
> > I think I may just give up--it was a minor detail and not requested by
> > the users.  Bugs me, though.  Seems like it shouldn't be so tricksy...
> >
> > On Jul 2, 3:12 pm, "Brian J. Fink" <[EMAIL PROTECTED]> wrote:
> >
> > > There may be a jQuery way to do this, but I don't know what it is.
> >
> > > However, I do know 2 ways to accomplish this: one DOM way, one IE way.
> > > Both methods must be employed.
> >
> > > $(function() {
> > >  $('input[type="text"]').bind('focus',function() {
> > >   window.o=this;
> > >   if (o.setSelectionRange) /* DOM */
> > >setTimeout('o.setSelectionRange(o.value.length,o.value.length)',2);
> > >   else if (o.createTextRange) /* IE */
> > >   {
> > >var r=o.createTextRange();
> > >r.moveStart('character',o.value.length);
> > >r.select();
> > >   }
> > >  });
> >
> > > });
> >
> > > On Jul 2, 2:55 pm, Paul Malan <[EMAIL PROTECTED]> wrote:
> >
> > > > By default it seems browsers select all the text in a textbox when it
> > > > gains focus by way of a tab-press.  I would like the cursor to be
> > > > positioned at the end of any existing text in the input,
> instead.  The
> > > > examples I'm turning up on Google don't work and seem needlessly
> > > > complex, and since jQuery simplifies everything else I used to hate
> > > > about Javascript, I thought I'd see if there's a simple way to
> > > > position the cursor in a text input box on focus.  Is it doable?
> >
> > > > Thanks...
>


[jQuery] Re: Passing a variable into the $('selector') function

2008-07-02 Thread Erik Beeson
If msg is '#myDiv' and you have element with id="myDiv", then $(msg) will
select it.

If you think that's what you're doing and it isn't working for you, either
your id is wrong or msg doesn't hold what you think (maybe it has a trailing
\n?).

--Erik


On 7/2/08, Stompfrog <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> I have a problem that I can't crack.
>
> I have a function similar to this..
>
>   $.ajax({
>type: "POST",
>url: "some.php",
>data: "name=John&location=Boston",
>success: function(msg){
>  alert( "Data Saved: " + msg );
>}
>   });
>
> The data that gets passed back to the function from some.php is a
> string which is the id of the div that I want to manipulate in the
> callback function e.g. "#myDiv".
>
> My question is how can I get that div from the callback function using
> the msg variable because $(msg); doesn't work and neither does $
> ("'"+msg+"'");
>
> Thanks in advance,
>
>
> Stompfrog
>
>
>
>
>
>


[jQuery] Re: unsubscribe me

2008-07-02 Thread Erik Beeson
Obligatory bash.org quote: http://bash.org/?244321

--Erik


On 7/2/08, Greg Hemphill <[EMAIL PROTECTED]> wrote:
>
>
> and your password is... just kidding I don't know your password.
>
>
> On Jul 2, 2008, at 1:07 PM, spicyj wrote:
>
> >
> > Your username is [EMAIL PROTECTED]
> >
> > On Jul 2, 11:05 am, "Rohit Mandlik" <[EMAIL PROTECTED]> wrote:
> >> Hi,
> >>
> >> How can i unsubscribe from this forum so i will not get more mails
> >> from this
> >> forum.
> >> I forgot my username and password.
> >> please help me
> >>
> >> thanks
> >> Rohit
>
>


[jQuery] Re: SproutCore vs jQuery? Are there any comparisons out there?

2008-06-17 Thread Erik Beeson

I guess maybe it'll be cool eventually since Apple is apparently
backing it? But from the demos so far, it looks extremely
half-baked...

--Erik


On 6/17/08, Andy Matthews <[EMAIL PROTECTED]> wrote:
>
>  Yeah...that's what I thought. I've never even heard of it before WWDC.
>
>
>  -Original Message-
>  From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>  Behalf Of Rey Bango
>  Sent: Tuesday, June 17, 2008 10:29 AM
>  To: jquery-en@googlegroups.com
>  Subject: [jQuery] Re: SproutCore vs jQuery? Are there any comparisons out
>  there?
>
>
>  There are no comparisons out at the moment. While SproutCore has recently
>  received a lot of press, it's been completely out of the limelight
>  otherwise.
>
>  Rey...
>
>  Andy Matthews wrote:
>  > I'm looking for comparisons between the newly popular JS library
>  > SproutCore and our own favorite, jQuery.
>  >
>  > Mostly I'm looking for feature comparisons in the area of data binding
>  > and UI.
>  >
>  > SproutCore's got to be good if Apple decided to use it for their
>  > recerntly announced MobileMe online app. But why? Why not jQuery, or
>  > Dojo, etc?
>  >
>  >
>  > *
>  > 
>  >
>  > Andy Matthews
>  > *Senior ColdFusion Developer
>  >
>  > Office:  615.627.9747
>  > Fax:  615.467.6249
>  > www.dealerskins.com 
>  >
>  > Total customer satisfaction is my number 1 priority! If you are not
>  > completely satisfied with the service I have provided, please let me
>  > know right away so I can correct the problem, or notify my manager
>  > Aaron West at [EMAIL PROTECTED]
>  >
>
>
>


[jQuery] Re: Is there a way to use the css function with $(document) directly?

2008-06-16 Thread Erik Beeson

This worked for me on FF2/Mac:

$('').attr('type', 'text/css').text('div { background:
red; }').appendTo('head');

--Erik


On 6/16/08, Brian J. Fink <[EMAIL PROTECTED]> wrote:
>
>  I didn't mean $(element).css(object), I meant $
>  (document).css(selector,rule). The difference is this: css() as it
>  stands makes a one-time change to the members of the jQuery object by
>  adjusting the style attribute of each. When a new element matching the
>  query string is created, it does not have the desired css values.
>  Trust me: I've already tested it.
>
>  What I'm talking about is a way to directly manipulate the document's
>  style sheets using jQuery.
>
>
>  On Jun 16, 4:32 am, Olaf Bosch <[EMAIL PROTECTED]> wrote:
>  > Brian J. Fink schrieb:
>  >
>  > > 
> $(document).css(selector1,rule1).css(selector2,rule2)...css(selectorN,ruleN);
>  >
>  > > If this is already part of the jQuery functionality, tell me the
>  > > syntax to use.
>  >
>  > Yes, it's ON:
>  >
>  >   $("p").css({ color: "red", background: "blue" });
>  >
>  > --
>  > Viele Grüße, Olaf
>  >
>  > ---
>
> > [EMAIL 
> > PROTECTED]://olaf-bosch.de/http://ohorn.info/http://www.akitafreund.de/
>  > ---
>


[jQuery] Re: $("#content").load('http://www.google.com.br') is a possible ?

2008-04-24 Thread Erik Beeson
Use an iframe or read up on cross domain ajax.

--Erik


On Thu, Apr 24, 2008 at 1:27 PM, Luciano Mazzetto <[EMAIL PROTECTED]>
wrote:

>
> Hi,
>
> I need loading http request inside my div content.
>
> I do this it
>
> $("#content").load("http://www.google.com.br";);
>
> but i hadn't sucess
>
> How i can load this page in my div ?
>
> tks..
>


[jQuery] Re: Which jQuery method to use in this scenario

2008-04-23 Thread Erik Beeson
The formSerialize function from the form plugin does exactly what you're
asking for:
http://www.malsup.com/jquery/form/#api


The form plugin also has a variety of functions for submitting forms via
ajax.

Hope it helps.

--Erik


On 4/23/08, neualex <[EMAIL PROTECTED]> wrote:
>
>
> Guys, I am new with jQuery, and I was trying to do something very
> simple for you at least.
>
> I am using jQuery against classic ASP pages and I need to send a form
> to a ASP page and come back with XML results.
>
> So, question: Is there an easy way to just identify the FORM and send
> all the element values by default without actually building up the
> "value string" in the $.post method.
>
> $.post("process.asp", { name: "neualex", pass: "password" },
>function(data){ alert(data);
> });
>
> I review the documentation, but to be honest I find it difficult. If
> you have samples on the scenario above in PHP or better yet ASP,
> please send them to me.
>
> I'd appreciate your support.
>
> Thanks,
>
> neualex
>


[jQuery] Re: Focus First 'visible' field

2008-04-21 Thread Erik Beeson
Your inner $(this).filter(...) doesn't make sense to me. This works for me
on FF2/Mac:
$(':input:visible').filter(function() {
return $(this).parents(':hidden').length == 0;
}).slice(0,1).focus();

That is: Select all visible inputs elements, filter out any who have parents
which are hidden, select the first one of those that remain, focus it.

--Erik

2008/4/21 Jacky See <[EMAIL PROTECTED]>:

>
> Someone found that this method does not handle visibility correctly.
> When a visibility:hidden parent with a visibility:show child, the
> child would override its parent's property (of course!).
> So the script only need to check display:none parent, which would
> introduce another filter:
>
> $(":text:visible:enabled").filter(function(){
> return $(this).filter(function(){
>   this.style.display == "none";
>}).size()==0;
> }).eq(0).focus();
>
> On 4月17日, 下午9時40分, Jacky <[EMAIL PROTECTED]> wrote:
> > To work on any type of input should be easy, just replace ':text' with
> > input.
> >
> > I know that IE would give error when you're focusing a 'disappearing'
> input.
> > (parent is hidden, for example). But I do not encounter any error like
> you
> > described. Any sample code for  your HTML?
> >
> > On Tue, Apr 15, 2008 at 9:00 AM, MichaelEvangelista <[EMAIL PROTECTED]>
> > wrote:
> >
> >
> >
> >
> >
> > > I've been looking for a solution like this, but that will work with
> > > any type of form input.
> > > The code I've been using is below (where form-id is the ID of the
> > > containing form)
> >
> > > It works great in Firefox but IE throws the error
> > > 'this.parentNode.borderCss.on' is null or not an object
> >
> > > I tried your example code above, and got the same error
> >
> > > here is what I was using :
> >
> > > // --- Put the cursor in the first field on page load
> > > var $firstfield = function(){
> > > $('#form-id input:eq(0)').focus();
> > > }
> > > $firstfield();
> >
> > > Could this have anything to do with my markup? I didnt get that error
> > > on your demo, but i did when I applied your code to my form.
> >
> > > On Apr 13, 7:54 am, Jacky  See <[EMAIL PROTECTED]> wrote:
> > > > Hi all,
> >
> > > > For focusing first input text field, the usual solution is $
> > > > (':text:visible:enabled:eq(0)').focus(). However, when these fields
> > > > are in an ':hidden' parent (not 'visible' by our eyes), it won't
> work.
> >
> > > > Currently I tried to solve this by:
> >
> > > > $(":text:visible:enabled").filter(function(){
> > > > return $(this).parents(":hidden").size()==0;
> >
> > > > }).slice(0,1).focus();
> >
> > > > I have setup a test page for this:
> > >http://www.seezone.net/dev/focusField.html
> > > > Try to toggle different parent to and click 'focus'. It should work
> > > > correctly.
> >
> > > > I would like to know if there is any other 'selector-based' way to
> do
> > > > so?
> >
> > --
> > Best Regards,
> > Jacky
> > 網絡暴民http://jacky.seezone.net
>


[jQuery] Re: What do you use?

2008-04-17 Thread Erik Beeson
Java.

See also, this thread:
http://groups.google.com/group/jquery-en/browse_thread/thread/ce0ddf8919cb9334/2613d125f737387d

--Erik

On Wed, Apr 16, 2008 at 4:31 AM, Chalkers <[EMAIL PROTECTED]> wrote:

>
> Hi jQueryers,
>
> I am curious what people use as on the server side with jQuery?
>
> PHP, ASP, Groovy/Java/Spring, RoR, something else or nothing, just
> plain old (x)HTML?
>
> I generally use PHP but have used it with Java and Grails.
>
> Regards,
> Andrew
>


[jQuery] Re: Find a exact location in the dom, then move down from that location to another element

2008-04-10 Thread Erik Beeson
I'm not quite sure what you're asking for, but it sounds like you might want
to check out the docs on selecting and traversing:

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

Hope it helps.

--Erik


On 4/10/08, sleepwalker <[EMAIL PROTECTED]> wrote:
>
>
> Is there a way in jquery to find your exact location in the dom and
> then move down from that location to another element? For example can
> I get the value of a input[text].someClass after changing it and write
> that change only to the next td.someOtherClass in the dom without
> using an id?
>


[jQuery] Re: Is there an Event.stop for hrefs?

2008-04-06 Thread Erik Beeson
Returning false is fine, but there's also event.preventDefault():
http://docs.jquery.com/Events_%28Guide%29#event.preventDefault.28__.29

$('a').click(function(e) { e.preventDefault(); });

--Erik


On 4/6/08, Michael Sharman <[EMAIL PROTECTED]> wrote:
>
>
> Hi guys,
>
> I am "listening" for an href click in my document.ready function and I
> want to make sure the href isn't followed by the browser for users who
> have javascript turned on, and is followed by users who have
> javascript turned off. This is my href:
>
> http://mysite.com/gohere.html"; id="hrefCreate">Click me
>
> The way I'm doing the javascript is (note the "return false"):
>
> $(document).ready(function(){
>
> $('a#hrefCreate').click(function(){
> //do something here
> return false;
> });
>
> });
>
> This is working fine (i.e. the "return false) but I just want to check
> if this is the best practice way to do this and if it's cross browser
> etc.
>
> The reason I ask is that in Prototype.js there is an Event.stop which
> halts all processing and allows you to do what you want in your
> function.
>
> Is there similar in jQuery or will return false suffice?
>
> Thanks guys.
>


[jQuery] Re: jEditable issue in Firefox 2.0.0.13

2008-04-05 Thread Erik Beeson
>
> (and is jEditable the best edit-in-place plugin for jQuery anyway?)
>

Yes.


[jQuery] Re: check/uncheck via toggle

2008-04-02 Thread Erik Beeson
Also, '[EMAIL PROTECTED]' can be replaced with ':checkbox'.

--Erik


On 4/2/08, Karl Rudd <[EMAIL PROTECTED]> wrote:
>
>
> The "toggle()" function is used to hide and show items, nothing to do
> with clicking or changing of state.
>
> http://docs.jquery.com/Effects/toggle
>
> What you want is something like:
>
> $('[EMAIL PROTECTED]').click(
> function() {
>   if ( this.checked )
>
>
> 
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000);
>
>   else
>
>
> 
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000);
> }
> );
>
>
> Karl Rudd
>
>
> On Thu, Apr 3, 2008 at 12:41 PM, Bruce MacKay <[EMAIL PROTECTED]>
> wrote:
> >
> >  Hello folks,
> >
> >  I have a table of data, with each row containing a checkbox.  What I
> want
> > users to be able to do is tick the box of each row of data they want to
> > delete (and after ticking, they will submit the form etc etc.
> >
> >  As a visual aid, I want to alter the background colour of the row - and
> if
> > they untick a selection, to reverse that background colour change.
> >
> >  My code as follows achieves the background colour toggle, but the
> > checkboxes are neither checked or unchecked.
> >
> >  I'd appreciate someone pointing out my error?
> >
> >
> >  $('[EMAIL PROTECTED]').toggle(
> >  function() {
> >$(this).attr('checked',true);
> >
> >
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000);
> >  },
> >  function() {
> >$(this).attr('checked',false);
> >
> >
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000);
> >  }
> >  );
> >
> >  Thanks
> >  Bruce
>


[jQuery] Re: missing ( before formal parameters

2008-03-05 Thread Erik Beeson
>
> missing ( before formal parameters
>
> $("#postcode").change(function{$("#town").val(zipToCityHash.$("#postcode").val()...
>

Also, I see what you're trying to do there, but you can't access object
properties like that. You probably want something like:

$("#postcode").change(function() {
$("#town").val(zipToCityHash[$("#postcode").val()]); });

Plus, you don't need to select #postcode again. You can access it with
'this' in the event handler:

$("#postcode").change(function() { $("#town").val(zipToCityHash[this.value]);
});

And, if the user enters a zip that isn't in your hash, val() will get passed
undefined, which does the same thing as calling val() with no arguments: it
returns the current value without changing it. So if you want to change or
clear town if the user enters a zip that isn't in your hash, you could do
something like:

$("#postcode").change(function() {
   if(zipToCityHash[this.value]) {
  $("#town").val(zipToCityHash[this.value]);
   } else {
  $("#town").val(""); // clear town, or whatever you want to do in this
case
   }
});

Hope it helps.

--Erik


[jQuery] Re: Attribute Selector

2008-02-25 Thread Erik Beeson
You have some oddly mismatched quotes, but otherwise, yes, that works.
Here's a test done in firebug on jquery.com:

>>> $('[EMAIL PROTECTED]:][href*=book]').each(function() { console.log(this.href
);});
http://www.packtpub.com/jQuery/book/mid/1004077zztq0
http://www.packtpub.com/jQuery/book/mid/1004077zztq0

Hope it helps.

--Erik


On 2/25/08, Smith, Allex <[EMAIL PROTECTED]> wrote:
>
>  Correct me if I am wrong...
>
> This selector should:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]>:"[EMAIL PROTECTED]"
> somedomain.com]
>
> only select
>
> links that start with "mailto:"; and contain "somedomain.com"
>
> Correct?
>
> Allex
>


[jQuery] Re: what editor do you use?

2008-02-13 Thread Erik Beeson
IntelliJ IDEA and gvim. I use gvim literally all the time. I have an icon on
my dock for "Open with gvim" that I can just drop files on. Very handy.

The nice thing about gvim (or vi in general I guess), is that while there
are a lot of commands, way more than anyone would be expected to learn all
in one sitting, the basic commands to get you started are pretty easy. i,
ESC, x, :wq are enough to get you started. And eventually you get tired of
deleting one character at a time, so you go lookup other delete commands,
and find dw to delete a word, and dd to delete a line. Then you figure out
that the d* commands cut, and p pastes. Then, when you get tired of doing
ddP to copy via cut-n-paste, you find yy copies ("yanks") without cutting.
You get tired of cutting one line at a time, so you find that prefixing any
command with a number makes it operate that many times.

Anyways, I could go on forever, but the point is it's not actually that
hard.

Oh, and IDEA is awesome also. Well worth the $$$. I just wish it had better
Scala support.

--Erik


On 2/13/08, Feijó <[EMAIL PROTECTED]> wrote:
>
>  I changed my own a few weeks ago, now I'm using Editpad++ (
> http://sourceforge.net/projects/notepad-plus/)
> its freeware, nice resources, like macros, quick-text, highlighted source,
> ...
>
> and yours?
>
> --
>
> Feijó
>
>


[jQuery] Re: Counting DIVs with class "x" within a larger DIV

2008-02-12 Thread Erik Beeson
Untested, but should work: $('#data .x').length

--Erik


On 2/12/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> Sure this is simple, still trying to get a handle on the basics of
> JQuery.  Given a DIV with id = "data", how would I count the number of
> DIVs with class = "x", within the larger DIV "data"?
>
> Thanks, - Dave
>


[jQuery] Re: How to logically AND selectors?

2008-01-30 Thread Erik Beeson
>
> You're looking for:.selector1.selector2.selector3
>

But, that's only if selector1, selector2, and selector3 are all classes,
yes?

--Erik


[jQuery] Re: How to logically AND selectors?

2008-01-30 Thread Erik Beeson
Generally, just run them together with no space.

A div tag with ID foo and class bar: div#foo.bar

Any tag with classes class1 and class2: .class1.class2

etc

Hope it helps.

--Erik


On 1/30/08, Kynn Jones <[EMAIL PROTECTED]> wrote:
>
>
> Hi.  The docs describe selectors of the form
>
>   selector1, selector2, selector3
>
> as "matching the combined results of all the specified selectors", by
> which they mean the set union of all the individual selections.  In
> other words, the ',' here behaves like a logical OR.
>
> Is there a succinct way to perform the correspond logical AND?  I.e.
> what's the best way to obtain the set intersection of multiple
> selections?
>
> TIA!
>
> kynn
>


[jQuery] Re: how to get php to detect if it's an ajax call or a normal full page call

2008-01-29 Thread Erik Beeson
The request header "X-Requested-With" is set to "XMLHttpRequest" for all
AJAX calls from jQuery.

Hope it helps.

--Erik


On 1/29/08, Alexandre Plennevaux <[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
>
> so that my php script can serve both ajax calls and full page call if
> javascript is not available on the client platform, i usually append a
> "js=1" to all links. So it's a child play to test for $_GET['js']==1 on the
> server and serve the relevant html.
>
> Now, i've switched my application to use pretty url, thus cannot use that
> trick anymore.
>
> I would like to know if there is another possibility, possibly in the
> http-header sent by jquery ?
>
> Thanks a lot for your help,
>
>
> Alexandre
>
>
>
>


[jQuery] Re: Feb 12 IE6 Forced Update

2008-01-24 Thread Erik Beeson
I don't usually run both at the same time, but I have, and it works. I'm on
a 2GHz Core 2 Duo iMac with 3GB of RAM (the most it will take). I use both
Parallels and Fusion because I started with Parallels, and it has more
features, but it's more resource intensive, so for things like video
conferencing from within Windows, Fusion works much better.

Seriously, I can not stress enough that getting a Mac has significantly
increased my web development productivity (can test FF Mac/Windows, Safari
Mac/Windows, IE6/7 (in true separate OS instances), Linuxes, etc). As has
dual screens (though I'd really like 3: one for code, one for the web
browser, and one for server logs/terminal).

I've been a diehard, build my own PC user forever, but now I tell everyone
to get a Mac.

Sorry to wonder OT.

--Erik


On 1/24/08, Mika Tuupola <[EMAIL PROTECTED]> wrote:
>
>
>
> On Jan 24, 2008, at 7:16 PM, Karl Swedberg wrote:
>
> > Of course you could also install two virtual machines, one with IE6
> > and one with IE7. I do this with my Mac and Parallels (Fusion also
> > works well), and I'm sure there are Windows VM apps out there.
>
> I could imagine running two Windowses at the same time is quite a
> memory hog. How much do you have? 10G ? :)
>
> --
> Mika Tuupola
> http://www.appelsiini.net/
>
>


[jQuery] Re: animation queue ?

2008-01-17 Thread Erik Beeson
Check out here:
http://erikandcolleen.com/erik/jquery/fxQueue/
Demo: http://erikandcolleen.com/erik/jquery/fxQueue/random.html

Or here:
http://brandonaaron.net/jquery/plugins/fxqueue/
Demo: http://brandonaaron.net/jquery/plugins/fxqueue/test/test.html

--Erik


On 1/17/08, Alexandre Plennevaux <[EMAIL PROTECTED]> wrote:
>
>
> hi friends,
>
> i'm storing the steps of a series of animations in an array, that have to
> occur one after the others, according to their index order  in the array.
>
> Example:  animArray['section', 'item','object1','object2' ];
>
> i would like to run a function that loops through the array, and for each
> element in the array, perform the animation, then when the animation is
> finished,  move on to the next element, do its related animation, etc...
> until the array is finished.
>
>
> Now, how do i make the animation queue one after the others?
>
>
> Thanks for any feedback/hint,
>
> Alexandre
>
>
>


[jQuery] Re: jQuery 1.1.2 Released: Happy 2nd Birthday!

2008-01-14 Thread Erik Beeson
I thought I was having a flashback as I swear I remembered 1.1.2 being
released a while ago:

http://jquery.com/blog/2007/02/27/jquery-112/

Ahh, a typo I see. At least it's right in the blog.

Congrats! Keep up the awesome work.

--Erik

On 1/14/08, John Resig <[EMAIL PROTECTED]> wrote:
>
>
> On the 2nd birthday of jQuery we're happy to bring you a new release of
> jQuery!
>
> Here's the announcement:
> http://jquery.com/blog/2008/01/15/jquery-122-2nd-birthday-present/
>
> and here's the release notes:
> http://docs.jquery.com/Release:jQuery_1.2.2
>
> Enjoy - and here's looking forward to another year of excellent jQuery
> code!
>
> --John
>


[jQuery] Re: Sorting with each()

2008-01-14 Thread Erik Beeson
I seem to be the only person to care about sort in jQuery. This ticket has a
sort function that worked with 1.1, though I'm not sure if it still does.
Make sure to scroll down to the bottom for the most recent version:

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

For example, to sort the children of an element with id "foo":

$('#foo').children().sort(function(a, b) { ... }).prependTo('#foo');

You have to reinsert them into the DOM after sorting them, and 'a' and 'b'
are DOM nodes, not jQuery objects.

Hope it helps.

--Erik


On 1/14/08, monster79 <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> I'm looking for an elegant method to sort elements returned from
> find() or an each() callback. Currently I'm dumping the elements' text
> into a Javascript array with push(), then sorting the array
> with .sort() and printing the results with a for() loop. This works
> well, but it doesn't seem like the jQuery way to do it. Any
> suggestions?
> Jonas
>


[jQuery] Re: a way to convert jquery object to text for dom injection

2008-01-14 Thread Erik Beeson
Maybe try (untested):

$('div').append('text blab bla').append($('#d')).append('ok nana');

--Erik

On 1/13/08, Equand <[EMAIL PROTECTED]> wrote:
>
>
> i need to insert a clone of one dom object
> i do
> var hex = $("#d").clone();
> $("div").append("text blab bla"+hex+"ok nana");
> and it's not working...
> how do i do this?
>


[jQuery] Re: [ANNOUNCE] Cornerz - Bullet Proof Curved Corners using Canvas/VML

2008-01-08 Thread Erik Beeson
Your choice of colors aside, this plugin looks fantastic! Very smooth.

If this had gradients and drop shadows, I could replace my photoshop guy
with it :)

--Erik


On 1/7/08, weepy <[EMAIL PROTECTED]> wrote:
>
>
> Hi I'd like to announce my latest jQuery plugin. I hope you'll find it
> useful.
>
> FEATURES:
>
> # Antialiased
> # Very Fast
> # Support for any size radius and border width with minimal
> performance increase
> # No excanvas
> # Current layout is maintained
> # Works with all tested positions/display/floats
> # Supports fluid layouts
> # Original div still shows through, so can easily do hover/background
> effects
> # Script is only 4.0k uncompressed
>
> Issues
> # IE6 has some slight problems with the VML in some cases
> # Mac/Safari doesn't work (Windows Safari is fine)
>
> You can see it in action here :
>
> http://www.parkerfox.co.uk/cornerz
>
> Look forward to your comments
>
> Jonah
>


[jQuery] Re: Fading out a text

2008-01-07 Thread Erik Beeson
Effect can be seen here: http://fortuito.us/

I think I would be inclined to overlay an alpha PNG to get that effect, not
javascript.

--Erik


On 1/7/08, JP <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I want to create an effect where text on the line starts to fade out
> after 100 characters. I though, I have seen such an effect somewhere
> but now I cannot find it. I think earlier Gmail inbox items were
> rendereder like that but maybe I just remember wrong because now they
> don't do that.
> Has anyone else seen such a functionality?
>


[jQuery] Re: (this).next problem

2007-12-24 Thread Erik Beeson
Siblings are tags who have the same parent. For example:

.

bar and far are siblings, foo and wax are siblings, far and wax aren't
siblings.

Maybe try this:

$('.collapse_device').click(function() {
  $(this).parents('.device_header').next().hide();
});

That will walk up the hierarchy to an element with class device_header, then
find the next sibling of that, which is your device_content.

Hope it helps.

--Erik


On 12/24/07, jody <[EMAIL PROTECTED]> wrote:
>
>
> hi all,
>
> I'm new to the list and new to jQuery, so I hope you can bear with me.
> I'm having a problem getting a specific div to hide without hiding
> similarly classed divs. The HTML looks something like this:
>
> 
> Device Name
> 
> - a> 
> 
> 
> 
> ---Device Information---
> 
>
> The jQuery I'd like to use looks like this:
>
> $('.collapse_device').click(function(){
> $(this).next('.device_content').hide() });
>
> If I write it as:
>
> $('.collapse_device').click(function(){
> $('.device_content').hide() });
>
> That works, but closes all the ".device_content" classes on the page
> and there could be, depending on the view, anywhere from 1-20 or
> more .device_content classes on the page.
>
> So, what am I doing wrong with (this).next and/or is there a better
> way to do what I'm trying to do? I've read around in the forums here
> and tried different methods but none seem to get at this exact
> problem. I've deduced that it may be to do with next requiring
> siblings--but I can't find clear documentation on just how strictly
> jQuery interprets the word "sibling"--if strictly, e.g. anchors are
> only siblings of anchors, then I can see the problem in that an anchor
> can't recognize the .device_content div as its sibling. But then I
> wonder if I'm thinking too hard about it?
>
> Thanks in advance,
> jody
>


[jQuery] Re: Select elements in order

2007-12-24 Thread Erik Beeson
See my responses regarding this issue in this thread:

http://groups.google.com/group/jquery-en/browse_thread/thread/c21d5c20bfd25f6c/f42894299920f05d?lnk=gst

--Erik


On 12/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> I want to select some items on my page in the order they appear, but
> it seems that jQuery selects them in the order that my selectors are
> written instead. So:
>
> $('h1,h2,h3')
>
> gets me all the h1s, then all the h2s, then all the h3s. Is there a
> way to get them in the order they appear in my document instead?
> Barring that, it's almost like I need a way to say "select all the
> h2's after this h1 UNTIL you find another h1 or an h3 ... "
>
> Any help would be appreciated!!
>
> Rebecca
> http://blog.rebeccamurphey.com
>


[jQuery] Re: clicking on row vs. clicking on link in that row

2007-12-22 Thread Erik Beeson
While returning false will stop the event from propagating, it will also
prevent the default action from occurring, which isn't necessarily
desirable. In this case it might not matter, but in general,
event.stopPropagation() is the "right" way to stop the event from
propagating. Returning false does both event.stopPropagation() and
event.preventDefault().

--Erik


On 12/21/07, Shawn <[EMAIL PROTECTED]> wrote:
>
>
> You probably need to return false from your click handlers
>
>  // highlight rows, load details
> $("#myTable tr").mouseover(function() {
> $(this).addClass("over");}).mouseout(function() {
> $(this).removeClass("over");
> }).click(function(){
> $(this).addClass("thisRow").siblings().removeClass("thisRow");
> var job = $(this).attr('id')
> var details = (job + '.htm')
> $("#console").load(details);
> return false;
> });
>
> $("#myTable a.ackn").click( function(){
> $(this).parents('tr').hide();
>  return false;
> });
>
> That *should* take care of things for you...
>
> Shawn
>
> rolfsf wrote:
> >
> > I've set up a simple action when a user clicks on a row in a table.
> > (highlight the row, load some details via ajax into a div)
> >
> > However, in one column of the table I've got a link/button that, when
> > clicked, will hide that row. If clicked, I don't want to highlight the
> row
> > or load it's details. How do I distinguish between the two?
> >
> >
> >   // highlight rows, load details
> >   $("#myTable tr").mouseover(function() {
> >   $(this).addClass("over");}).mouseout(function() {
> >   $(this).removeClass("over");
> >   }).click(function(){
> >
> $(this).addClass("thisRow").siblings().removeClass("thisRow");
> >   var job = $(this).attr('id')
> >   var details = (job + '.htm')
> >   $("#console").load(details);
> >   });
> >
> >
> >   // hide a row after acknowledgement
> >   $("#myTable a.ackn").click( function(){
> >   $(this).parents('tr').hide();
> >   });
> >
> > thanks,
> > r.
>


[jQuery] Re: clicking on row vs. clicking on link in that row

2007-12-21 Thread Erik Beeson
Maybe try:

   // hide a row after acknowledgement
   $("#myTable a.ackn").click( function(e){
   e.stopPropagation();
   $(this).parents('tr').hide();
   });

See also:
http://docs.jquery.com/Events_(Guide)#event.stopPropagation.28__.29

--Erik


On 12/21/07, rolfsf <[EMAIL PROTECTED]> wrote:
>
>
>
> I've set up a simple action when a user clicks on a row in a table.
> (highlight the row, load some details via ajax into a div)
>
> However, in one column of the table I've got a link/button that, when
> clicked, will hide that row. If clicked, I don't want to highlight the row
> or load it's details. How do I distinguish between the two?
>
>
> // highlight rows, load details
> $("#myTable tr").mouseover(function() {
> $(this).addClass("over");}).mouseout(function() {
> $(this).removeClass("over");
> }).click(function(){
>
> $(this).addClass("thisRow").siblings().removeClass("thisRow");
> var job = $(this).attr('id')
> var details = (job + '.htm')
> $("#console").load(details);
> });
>
>
> // hide a row after acknowledgement
> $("#myTable a.ackn").click( function(){
> $(this).parents('tr').hide();
> });
>
> thanks,
> r.
> --
> View this message in context:
> http://www.nabble.com/clicking-on-row-vs.-clicking-on-link-in-that-row-tp14464501s27240p14464501.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com
> .
>
>


[jQuery] Re: creating own callback

2007-12-21 Thread Erik Beeson
I doubt that will work. There need not be anything particularly "jQueryish"
about preloading images, but if you want to stick it under $, maybe
something like:

jQuery.extend({
   preloadImage: function(imagePath,callback) {
 var image = new Image();
 if(jQuery.isFunction(callback)) image.onload = callback;
 image.src = "gfx/"+imagePath;
   }
});

--Erik


On 12/21/07, Jake McGraw <[EMAIL PROTECTED]> wrote:
>
> I'm sure there's a more sophisticated way of doing this, but functions can
> be passed around like any other variable type in JavaScript, so:
>
> jQuery.extend({
>preloadImage: function(imagePath,callback) {
>  jQuery("").attr("src", "gfx/"+imagePath);
>  callback();
>}
> });
>
> Should do the trick.
>
> - jake
>
> On Dec 21, 2007 3:11 PM, Eric Teubert < [EMAIL PROTECTED]> wrote:
>
> >
> > Hi,
> >
> > I spend some time in browsing through the documentation but I didn't
> > find anything about creating own functions with callback-
> > functionality. How do I do this?
> >
> > What I want to do:
> > Write a function that preloads an image and returns a callback when
> > the image is loaded. It looks like
> >
> > jQuery.extend({
> >preloadImage: function(imagePath) {
> >jQuery("").attr("src", "gfx/"+imagePath);
> >}
> > });
> >
> > $.preloadImage("example.gif ");
> >
> > But how have I to edit the first part when I want the second to look
> > like the following?
> >
> > $.preloadImage("example.gif", function() { alert("Preloading
> > finished"); });
> >
> > Thanks!
> >
>
>


[jQuery] Re: Plugin for code highlighting and row numbering?

2007-12-20 Thread Erik Beeson
Chili is probably your best bet. I whipped up a little example that does a
little post processing to add line numbers:

http://erikandcolleen.com/erik/projects/jquery/chililineno/

There might already be an option for it in Chili, and there's probably a
smother way to apply it than I'm doing, but I'm in a hurry, and what I did
works, so it should at least get you started. It would probably be nice if
this was just an option to Chili.

Only tested on FF2/Mac.

--Erik


On 12/20/07, Shawn <[EMAIL PROTECTED]> wrote:
>
>
> I know I saw something a while ago, but can't seem to see it on the
> Plugins page.  I'm looking for a plugin that can do syntax coloring and
> row numbering for when I need to post code samples to my web pages.
>
> The best I've found so far is Chili for the syntax coloring.  But it's
> samples don't seem to indicate it can do row numbering.
>
> Any tips?  (apologies if I'm just being blind).
>
> Shawn
>


[jQuery] Re: Stupid little game :)

2007-12-19 Thread Erik Beeson
Fun, thanks for sharing :)

--Erik


On 12/19/07, Stefan Petre <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I did a small game (it was a test for a client), about 6kb of code.
> http://www.eyecon.ro/slotmachine/
>
> Stefan
>


[jQuery] Re: animation: sequential showing / hiding : how-to?

2007-12-17 Thread Erik Beeson
A google search for jquery fxqueue also turns up these:

http://erikandcolleen.com/erik/jquery/fxQueue/
http://brandonaaron.net/jquery/plugins/fxqueue/

Not sure if they'll work with newer versions of jQuery, but maybe worth
checking out.

--Erik


On 12/17/07, pixeline <[EMAIL PROTECTED]> wrote:
>
>
> thanks that 's excellent! i'll see if i can turn that into a plugin,
> maybe as an optional argument to the show function
>
> On 17 déc, 04:22, wick <[EMAIL PROTECTED]> wrote:
> > Here's the method I use on my site (modified a bit to fit your
> > example), there's probably a better way, but my version is pretty
> > clean:
> >
> > function showitems(i,max) {
> >   if (i <= max) {
> > $('div.items:eq('+i+')').show('slow',function() { showitems(+
> > +i,max) });
> >   }
> >
> > }
> >
> > $(function() {
> >   showitems(0,$('div.items').length);
> >
> > });
> >
> > It's a neat effect, I use it on my site CarComplaints.com for instance
> > here:http://www.carcomplaints.com/Ford/Focus/2001/
> >
> > On Dec 16, 6:15 pm, "Alexandre Plennevaux" <[EMAIL PROTECTED]>
> > wrote:
> >
> > > hi!
> >
> > > i'm displaying a series of graphical items in one command:
> >
> > > $('div.items").show("slow");
> >
> > > now, it was suggested by my mate that they appear one after the other,
> > > according to, say, their order of appearance in the html markup.
> >
> > > of course i could use the callback of each show so taht the next one
> only
> > > start when current is finished animating, but i don't know in advance
> the
> > > amount of divs there will be so i'm kind of stuck on how to achieve
> that.
> >
> > > Has anyone achieved something like that? Any clue would be useful.
> >
> > > Thank you,
> >
> > > --
> > > Alexandre
>


[jQuery] Re: Shared variables, events, and namespaces...

2007-12-13 Thread Erik Beeson
If you're just looking to keep from polluting the global namespace, you can
wrap all of your code in a closure. Lots of info here:
http://www.google.com/search?q=javascript+closures

For example (untested):

(function() {
  var ele = '#foo';
  $(document).ready(function() {
   $(ele). // ... Do something with 'ele'...
  });
  $(window).load(function () {
   $(ele). // ... Do something with 'ele'...
  });
})();

Then ele will just be available for the scope of your closure. Also, if you
really are doing something like your example, you might as well cache the
jQuery object instead of the selector to save having to look it up twice. A
good convention is to start variable names that point to a jQuery object
with $, like so:

(function() {
  var $ele = $('#foo');
  $(document).ready(function() {
   $ele. // ... Do something with 'ele'...
  });
  $(window).load(function () {
   $ele. // ... Do something with 'ele'...
  });
})();

Hope it helps.

--Erik


On 12/13/07, Micky Hulse <[EMAIL PROTECTED]> wrote:
>
>
> Just wondering what would be the best way to handle shared variable(s)
> between different events... for example:
>
> var ele = '#foo';
> $(document).ready(function() {
> $(ele). // ... Do something with 'ele'...
> });
> $(window).load(function () {
> $(ele). // ... Do something with 'ele'...
> });
>
> To me, the above seems a little sloppy... Is there a good way to
> contain the variable "ele" within it's own (relevant) namespace?
>
> Maybe I should be learning/reading about classes (OOP) and jQuery?
>
> Am I thinking too hard about this? :D
>
> I would greatly appreciate tips and/or suggestions.
>
> Have a great day/night!
> Cheers,
> Micky
>


[jQuery] Re: Cross domain photo gallery using get().

2007-12-08 Thread Erik Beeson
Hi Andy,

Neat idea. What you want for remote data is JSONP, which just requires that
your server produce a chunk of javascript that calls a function with a
specified name and passes in your data as a JSON block. So instead of
generating an HTML fragment, your data.cfm would take a parameter called
jsoncallback, and generate code like:

({ data: "my html fragment"});

Then in jQuery you do:

$.getJSON("http://www.commadelimited.com/code/whiskerino/data.cfm?jsoncallback=?
",{
username:options['username'],
size:options['size']
}, function(data){
$targetDiv.html(data.data).cycle('fade');
});

However, having said all that, since your script is already a remote
JavaScript, my suggestion is just to make your js file be dynamic and
include the data in it directly. Then your users could just specify their
options in the url to your javascript file, like so:

http://www.commadelimited.com/code/whiskerino/whiskerino.js?username=creole&divID=theDiv
" type="text/javascript">

And you would generate a script with the proper data already included
directly in the script. Something like (in your generated whiskerino.js):

$(document).ready(function(){
$('#').html("").cycle('fade');
});

Or if they didn't supply a username, you could render an error message
instead:

$(document).ready(function(){
$('#').html('Please
indicate your Whiskerino moniker.').cycle('fade');
});

Also, if you don't do it like I'm suggesting, I suggest that you at least
wrap the whole thing in a function instead of requiring a global object
called "options". In whiskerino.js have something like:

function whiskerino(options) {
  $(document).ready({
   /* your code */
  });
}

And  then your users include your your script and call your function and
pass in their options:


http://www.commadelimited.com/code/whiskerino/whiskerino.js";
type="text/javascript">





But the dynamic script way that I suggested would fix that too.

Hope it helps.

--Erik


On 12/8/07, Andy Matthews <[EMAIL PROTECTED]> wrote:
>
> I'm participating in an event in which you post photos of yourself
> each day ( http://www.whiskerino.org/2007/creole/). The organizer of
> the event created RSS feeds for each participant. I thought it would
> be fun, and a good challenge to write a photo gallery using the Cycle
> plugin that could be used by any of the participants (http://
> www.commadelimited.com/code/whiskerino/slideshow.cfm).
>
> It works great on my server, but I mistakenly assumed that the local
> reference data.cfm (the file that does the work) made in the JS file
> would always be made on my server. I just tried it locally and I'm
> getting the dreaded cross domain XmlHttpRequest error. I want this to
> work without the user have to install any code, or even have a hosting
> company that offers a scripting language. I wonder now if this is even
> possible.
>
> On data.cfm, I'm using ColdFusion to read in the RSS feed, then I'm
> looping over the feed and outputting the contents into div tags. You
> can see the results here:
> http://www.commadelimited.com/code/whiskerino/data.cfm
>
> Can any of you suggest an alternate method that would work?
>


[jQuery] Re: which query is most efficient?

2007-12-04 Thread Erik Beeson
console.time("$('p span')");
for(var i = 0; i < 1000; i++) $('p span');
console.timeEnd("$('p span')");

console.time("$('p').find('span')");
for(var i = 0; i < 1000; i++) $('p').find('span');
console.timeEnd("$('p').find('span')");

$('p span'): 863ms
$('p').find('span'): 3050ms

And from the profiler:

$('p span'): 390 function calls $('p').find('span'): 830 function calls

Though the function is always "e", so it isn't very useful for actual
profiling, but at least it gives you an idea of how much work is being done.

--Erik


On 12/4/07, Gordon <[EMAIL PROTECTED]> wrote:
>
>
> I couldn't tell you which one is faster, but if you want to find out
> for yourself then you can use the profiler in FireBug.  It's an addon
> for FireFox that has some powerful javascrip tools included.  Write a
> short script with a function that runs the selector you want to
> profile in a loop, say 100 iterations, and then call it while the
> profiler is running.
>
> On Dec 3, 10:58 pm, sawmac <[EMAIL PROTECTED]> wrote:
> > is there a difference in performance for these two:
> >
> > $('p span')
> >
> > $('p').find('span')
> >
> > while, I'm on the subject, what's a good way to test performance of
> > queries (and scripts in general)
> >
> > thanks
> >
> > --dave
>


[jQuery] Re: A 5 line script that doesn't work in IE

2007-12-01 Thread Erik Beeson
To check if an element has a particular class: $(...).is('.theClass');
To add a class to an element: $(...).addClass('theClass');
To remove a class: $(...).removeClass('theClass');

See also:
http://docs.jquery.com/Traversing/is#expr
http://docs.jquery.com/Attributes/addClass#class
http://docs.jquery.com/Attributes/removeClass#class
http://docs.jquery.com/Attributes/toggleClass#class

See if those help. Good luck.

--Erik


On 12/1/07, Gordan <[EMAIL PROTECTED]> wrote:
>
>
> I'm loosing my mind over this :-(
> http://www.writesomething.net/users/ ("show classical users list"
> link)
> I have a few lines of code which are extremly simple and work as
> expected in FF, but IE is refusing to cooperate :-(
> I tried literally everything but it just returns the "expected
> identifier, string or number" error.
> Please help, this has to be some simple bug that I'm overseeing :-
> ( thank you
> here's the complete code, and I use the latest 1.2.1 jQuery: (IE says
> that the error is on the 3rd line)
>
> function change_users_display() {
> if ($('#users').attr('class') == 'users_cloud') {
> $('#users').attr({class: ''});
> $('#change_users_display_classical').show();
> $('#change_users_display_cloud').hide();
> } else {
> $('#users').attr({class: 'users_cloud'});
> $('#change_users_display_classical').hide();
> $('#change_users_display_cloud').show(); }
> return true; }
>


[jQuery] DateJS: Robust Date manipulation library

2007-11-27 Thread Erik Beeson
Hello all,

This came through my feed reader this morning, and I thought it looked like
the kind of thing jQuerians might enjoy:

http://www.datejs.com/

It's a Date library with lots of parsing capabilities and jQuery style
chainable syntactic sugar. It's ~25k minified (!), so it's probably not for
everyone, but I can imagine a lot of places where something like this would
be very helpful.

Cheers!

--Erik


[jQuery] Re: Passing extra data to AJAX handler functions

2007-11-27 Thread Erik Beeson
You could wrap your real callback in an anonymous function that adds the
parameters that you want. Maybe something like (untested):

  $.post('/ajax/asset/insert', {
folder_tid : lastUploadedFolderTID,
link   : linkQueue[id]
  }, function(data, status) { handleAddLinkComplete.call(this, data,
status, 123); }, 'json');

Good luck with it.

--Erik


On 11/27/07, Rob Barreca <[EMAIL PROTECTED]> wrote:
>
>  I commonly want to pass an ID or some other information I know to an AJAX
> success handler.
>
>   $.post('/ajax/asset/insert', {
> folder_tid : lastUploadedFolderTID,
> link   : linkQueue[id]
>   }, handleAddLinkComplete, 'json');
>
>
> In this example, I want to pass an ID to handleAddLinkComplete function. I
> know I can do the following, but they seem crufty to me.
>
>
>1. I can set a global variable with the link ID, but what if I have
>a bunch of post calls, there are synchronous issues (I know I can do async 
> :
>false too)
>2. I could have my /ajax/asset/insert callback return the link ID
>back to me in the response, but it seems silly if I already know it.
>
> I would love to do something like...
>
>   $.post('/ajax/asset/insert', {
> folder_tid : lastUploadedFolderTID,
> link   : linkQueue[id]
>   }, { callback : handleAddLinkComplete, arguments : [123] }, 'json');
>
> or something.
>
> What is the best way here or is my dream a reality?
>
> Cheers,
>
> -Rob
>


[jQuery] Moo based Calendar widget

2007-11-05 Thread Erik Beeson

Here's a very slick calendar widget built on mootools:

http://moomonth.com/

Demo here:

http://moomonth.com/demo/index.html

It looks like it also has a number of handy additions to the Date
object that might be useful outside of mootools:

http://moomonth.com/docs/index.html

--Erik


[jQuery] Re: $('.class1,.class2').filter(':first') always finds first .class1

2007-11-05 Thread Erik Beeson

> > Your issue doesn't actually have anything to do with the filter, it's
> > the selection. $('.class1,.class2') selects all class1, then all
> > class2.
>
> This totally explains why I have the issue, and I thank you for
> describing it.  I expected the select element statement to behave
> something like, "className ~= /^(?:class1|class2)$/," but it really
> operates more like, "(.class1).push(.class2)."

In fact, there's even a comment about this in the docs:
http://docs.jquery.com/Selectors/multiple#selector1selector2selectorN
"Note order of the dom elements in the jQuery object aren't
necessarily identical."

However, this seem to do what you want, albeit probably a little slower:
$('*').filter(function() {return $(this).is('.class1,.class2');})...;

Though you should probably use something a little more specific than *
as the initial selector. Maybe ':input' to search all inputs, or
'#myForm *' or '#myForm :input' to only search children of your form.

Hope it helps.

--Erik


[jQuery] Re: $('.class1,.class2').filter(':first') always finds first .class1

2007-11-05 Thread Erik Beeson

Your issue doesn't actually have anything to do with the filter, it's
the selection. $('.class1,.class2') selects all class1, then all
class2. So even if class2 appears before class1, class one will still
get selected first (since you specified it first in the selector), and
your filter will return it.

I suggest you apply the same class to all elements that you want to
select from. If nothing else, you could do:

$('.class1,.class2').addClass('class1_or_class2');
$('.class1_or_class2').filter(':first')...;

And that second line could be simplified to:
$('.class1_or_class2:first')...;

Hope it helps.

--Erik


On 11/5/07, Pyrolupus <[EMAIL PROTECTED]> wrote:
>
> Basically, what I want to do is find the first element that matches
> either class1 OR class2.  However, using the syntax from the subject
> line:
>
>   var $jqElem = $('.class1,.class2').filter(':first');
>
> $jqElem is always the first element that has class1 (i.e., the first
> class specified), rather than the first element for the whole
> selector.  E.g., using the above on the following:
>
>   
>   
>
> it is getting "elem2."
>
> Am I using the wrong syntax?  I also tried $
> ('.class1').add('.class2').filter(':first'), but I get the same
> result.
>
> Thanks,
> Pyro
>
>


[jQuery] Re: Alternatives to dom ready() for running Jquery code

2007-11-01 Thread Erik Beeson
Move your javascript to the bottom of the page, right before , or use
$(window).load(...) instead, if you can handle your javascript not running
until all of your external resources (read: images) have loaded.

I think this should be fixed "soon".

--Erik


On 11/1/07, Brett <[EMAIL PROTECTED]> wrote:
>
>
> Hey all, I've ran into a problem where I get code that runs
> occasionally on IE6 and IE7.  It's working fine in Firefox, of
> course :/
>
> The code I have is:
>
> $(document).ready(function(){
> //$(function()
>headline_count = $("div.headline").size();
>$("div.headline:eq("+current_headline+")").css('top','5px');
>
>headline_interval = setInterval(headline_rotate,9000); //time in
> milliseconds
>$('#scrollup').hover(function() {
>  clearInterval(headline_interval);
>}, function() {
>  headline_interval = setInterval(headline_rotate,9000); //time in
> milliseconds
>  headline_rotate();
>});
>
> function headline_rotate() {
>
>current_headline = (old_headline + 1) % headline_count;
>$("div.headline:eq(" + old_headline + ")").animate({top:
> -205},"slow", function() {
>  $(this).css('top','210px');
>});
>$("div.headline:eq(" + current_headline + ")").show().animate({top:
> 5},"slow");
>old_headline = current_headline;
> }
>
> // End of headline code
>
>
> });
>
> but I guess the important part is:
>
> $(document).ready(function(){   });
>
> Ready just doesn't seem to fire correctly for me all the time.
>
> Looking at a previous post which kind of covered this :
>
> http://groups.google.com/group/jquery-en/browse_thread/thread/ae511652b94433fa/819f718c882c9ba2?lnk=gst&q=ready()#819f718c882c9ba2
> They couldn't get a definate answer neither.
>
> I just want to ensure that the headlines do appear all the time, at
> the moment I'm left with a white box sometimes.
>
> live link to test is:
> http://cressaid.brettjamesonline.com/bvci/
>
>


[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread Erik Beeson
Untested:





$('form').bind('submit', function() {
  var ext = $('#file').val().split('.').slice(-1).toLowerCase();
  if(ext != 'jpg' && ext != 'jpeg') {
alert('JPEG Only');
return false;
  }
});

--Erik


On 10/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> so where to attach the code? in the onClick of submit button?
>
> On Nov 1, 12:04 am, Giovanni Battista Lenoci <[EMAIL PROTECTED]>
> wrote:
> > [EMAIL PROTECTED] ha scritto:> Hi,
> >
> > > I'm using this to upload file:
> >
> > > 
> >
> > > It works very well, now I'd like to find a way to check only jpeg
> > > files are uploaded, any way to do this in jQuery? Thanks.
> >
> > > A.C.
> >
> > I think the only thing you can do client-side is to check the extension.
> >
> > $pieces = $('#file')[0].value.split('.');
> > $extension = $pieces[$pieces.length-1].toLowerCase();
> > if($extension == 'jpg' || $extension == 'jpeg') {
> >   alert('accepted');
> >
> > }
>
>


[jQuery] Re: .attr("type","hidden")

2007-10-29 Thread Erik Beeson
See also, this thread:

http://groups.google.com/group/jquery-en/browse_thread/thread/b1e3421d00104f17/88b1ff6cab469c39

--Erik


On 10/29/07, Robert O'Rourke <[EMAIL PROTECTED]> wrote:
>
>
> Hi, does $("some selector").attr("type","hidden") work for anyone?
>
> I'm getting this in firebug:
>
> [Exception... "'type property can't be changed' when calling method:
> [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e
> (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]
>
> Cheers,
> Rob
>


[jQuery] Re: jquery plugin + problem with return for "this" element

2007-10-25 Thread Erik Beeson
Despite the fact that you code is a bit of a mess, your problem is just that
since you aren't defining the variable "callback" with "var callback = ...",
it's being made a global variable, and as a global variable, each time you
call $(...).test1(...), you're overwriting "callback". Same for ttt. Adding
var before callback and ttt fixes the problem.

Good luck with it.

--Erik

On 10/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> > You're not getting 'this' correct.  Where you set 'b', 'this' is the
> > jQuery object, not an element.  So 'b' is a jQuery object that wraps
> > three dom elements.  Here's a hint:
> >
> > (function($) {
> > $.fn.test2 = function(color) {
> > // 'this' is the jQuery object
> > return this.each(function() {
> > // 'this' is a DOM element
> > var $el = $(this);
> > $el.bind('click', function() {
> > // this is the DOM element again
> > $el.css('color',color);
> > }
> > }
> > }
> >
> > })(jQuery);
>
> http://bynight.me.uk/jquery/mike.php
>
> Still its not okay, but...
>
> When I use
> b.bind('click', function() { b.css('color',color);}
> it works fine, but when I try:
>
> callback = function(data) {
> b.css('color',color);
> }
> ttt= function() {
> callback();
> }
> b.bind('click',ttt);
>
> I have result as you see on my page...
>
> ...
> To be more specific...
> I want use my plugin like that:
> callback = function() { ...}
> $('#something').test('option',callback);
> or $('#something').test('option',function() {...});
>
> thats why I want to have my function (ttt or callback) outside of
> b.bind(..)
>
> Thanks.
> Michael
>
>


[jQuery] Re: Selecting with "this"

2007-10-24 Thread Erik Beeson
Sounds like you only want the 'pointer' class and click handler to be
applied to the first 'p'? Maybe something like this (untested):

$('#texto>ol>li>p+*').hide();
$('#texto>ol>li>p:eq(0)').addClass('pointer').click(function(){
 $(this).siblings().toggle();
});

See: http://docs.jquery.com/Traversing/siblings#expr

Hope it helps (and works).

--Erik


On 10/24/07, linsms <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> I want to make a really simply thing: hide and show "p" elements in a
> list clicking in the first "p"
> I have this code in document.ready function:
>
> $('#texto>ol>li>p+*').hide();
> $('#texto>ol>li>p').addClass('pointer');
> $('#texto>ol>li>p').click(function(){
> $('this+*').toggle(); <- this is not working
> });
>
> I've try $('+*',this).toggle(); but it only matches the first element
> after this and I want to match all elements in list after this element
> (all brothers)
>
> Any ideas?
> Thanks
>
>


[jQuery] Re: "Gotcha" in the ajax call

2007-10-21 Thread Erik Beeson
That parameter is added when you set the 'cache' property to false. Are you
doing that?

--Erik


On 10/21/07, M. A. Sridhar <[EMAIL PROTECTED]> wrote:
>
>
> When making a GET call via jQuery.ajax, jQuery 1.2.1 adds a URL
> parameter named '_' (the single underscore character) whose value is
> the current time stamp. I'm not sure I understand why, and in any
> case, this caused me some grief when I tried to use it in a Facebook
> app. The reason is that the Facebook API requires a "signature"
> parameter as part of each request, and this parameter is basically the
> MD5 hash of the rest of the parameters. So the extraneous jQuery
> parameter was not being accounted for in my code, causing Facebook to
> complain about an incorrect signature.
>
> Perhaps someone can explain the need for this parameter. And perhaps
> it can be made optional in a future release?
>
> Just my $0.02.
>
> Regards.
>
>


[jQuery] Re: How to suck web content from an iframe to a div

2007-10-19 Thread Erik Beeson
IIRC, sub-domains can also be made to work if all pages involved set the
same document.domain

But back to the OP, your iframe can deal with scrolling itself if you set
its size in the containing page, and that you can do cross-domain. Maybe I
don't quite get what you're trying to do...

--Erik


On 10/19/07, Mike Alsup <[EMAIL PROTECTED]> wrote:
>
>
> Julian,
>
> Getting the contents from an IFrame served from the same domain works
> fine.  The security only kicks in for x-domain content.
>
> Mike
>
> On 10/15/07, juliandormon <[EMAIL PROTECTED]> wrote:
> >
> >
> > Thanks Mike,
> > That makes sense.
> > And what if it was the same domain? This is also the case with our new
> site.
> > I should have been more specific. I apologize.
> >
> >
> >
> > malsup wrote:
> > >
> > >
> > > Julian,
> > >
> > > You cannot access the contents of an IFrame which is sourced from a
> > > different domain.  This is part of the browser's cross-domain security
> > > model.
> > >
> > > Mike
> > >
> > >
> > > On 10/15/07, juliandormon <[EMAIL PROTECTED]> wrote:
> > >>
> > >>
> > >> Hoping anyone can help.
> > >> I use a custom scroll bar jquery plug-in which requires the content
> to be
> > >> within a DIV.
> > >>
> > >> Some of the content I want to load is from other web sites.
> > >>
> > >> I am pretty sure it is possible to load the content into a hidden
> iframe
> > >> and
> > >> then, once it has finished loading, suck the data in the iframe into
> my
> > >> div
> > >> and then apply my scrollbar plugin to the newly fitted div.
> > >>
> > >>
> > >> What's the proper method and plug-ins used to achieve this please?
> > >>
> > >> What are some of the pitfalls in doing this, if any?
> > >> --
> > >> View this message in context:
> > >>
> http://www.nabble.com/How-to-suck-web-content-from-an-iframe-to-a-div-tf4630767s27240.html#a13223056
> > >> Sent from the jQuery General Discussion mailing list archive at
> > >> Nabble.com.
> > >>
> > >>
> > >
> > >
> >
> > --
> > View this message in context:
> http://www.nabble.com/How-to-suck-web-content-from-an-iframe-to-a-div-tf4630767s27240.html#a13223518
> > Sent from the jQuery General Discussion mailing list archive at
> Nabble.com.
> >
> >
>


[jQuery] Re: prevent checkbox to check when click

2007-10-18 Thread Erik Beeson
.click(...) and .bind('click', ...) should do the same thing. What version
of jQuery are you using? This also works for me, again on FF2/Mac:

$(':checkbox').bind('click', function(e) {
  this.blur();
  e.preventDefault();
});

--Erik


On 10/18/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
> is that different if I use .click() instead of .bind()? because it
> doesn't work for me
>
> thanks
>
> On Oct 19, 1:57 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
> > Just return false from a click handler. The box will be focused, which
> > will change the way it looks a little, so you may also want to blur
> > it. Something like:
> >
> > $(':checkbox').bind('click', function() {
> >   this.blur();
> >   return false;
> >
> > });
> >
> > Tested on FF2/Mac.
> >
> > --Erik
> >
> > On 10/18/07, james_027 <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > hi,
> >
> > > how do i prevent the checkbox to be check when click if it doesn't
> > > meet certain requirements?
> >
> > > Thanks
>
>


[jQuery] Re: Case-insensitive version of :contains(text) ?

2007-10-18 Thread Erik Beeson
You could add your own expression for it (tested on FF2/Mac):

jQuery.extend(jQuery.expr[':'], {
  containsIgnoreCase: "(a.textContent||a.innerText||jQuery
(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0"
});

Usage:

$('...:containsIgnoreCase("foo")');

Or you could use a filter that would work basically the same way.

--Erik


On 10/13/07, RichUncleSkeleton <[EMAIL PROTECTED]> wrote:
>
> The selector :contains(text) appears to be case sensitive (though
> there's no mention of this in the jQuery docs). Is there a case
> insensitive version?
>
>


[jQuery] Re: prevent checkbox to check when click

2007-10-18 Thread Erik Beeson

Just return false from a click handler. The box will be focused, which
will change the way it looks a little, so you may also want to blur
it. Something like:

$(':checkbox').bind('click', function() {
  this.blur();
  return false;
});

Tested on FF2/Mac.

--Erik


On 10/18/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> how do i prevent the checkbox to be check when click if it doesn't
> meet certain requirements?
>
> Thanks
>
>


[jQuery] Re: OT Changing S=style sheet with javascript or jquery?

2007-09-27 Thread Erik Beeson
A google search for 'jQuery stylesheet switcher' turns up:

http://kelvinluck.com/article/switch-stylesheets-with-jquery

--Erik


On 9/27/07, Eridius <[EMAIL PROTECTED]> wrote:
>
>
>
>
> http://demo.sugarondemand.com/sugarcrm_os/index.php?action=index&module=Home
>
> if you click on the blocks of color at the top, i don't know if they are
> just change the css on the fly or completely loading a new css file.  Is
> it
> possible to load a different css file on the fly with javascript itself or
> with jquery easier?
> --
> View this message in context:
> http://www.nabble.com/OT-Changing-S%3Dstyle-sheet-with-javascript-or-jquery--tf4532015s15494.html#a12933318
> Sent from the JQuery mailing list archive at Nabble.com.
>
>


[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Erik Beeson
As I said to you offlist, it doesn't work that way. The value from $.get CAN
NOT be returned from isTracked because isTracked will have returned before
the $.get callback executes. Instead of:

if(isTracked(code) == 'true') {
  // thing A
} else {
  //thing B
}

You have to do:

isTracked(code, function(tracked) {
  if(tracked == 'true') {
// thing A
  } else {
//thing B
  }
});

In JavaScript, there's only 1 thread of execution. There's no
multithreading, and no "waiting". If you want something to run, that isn't
ready to run right now, you have to use some sort of callback that can get
run when it is ready.

--Erik


On 9/27/07, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:
>
>
>
> Michael Geary wrote:
> > You're still expecting things to happen in the wrong order. It's *inside
> the callback* that the data becomes available, and this is
> > long after isTracked() returns. Try this instead:
>
> Yes, but I want have a function that will return what i get from
> istracked.php
> to use it like that:
>
> function isTracked(...)
> {
> $.get('istracked.php',...);
> return value_from_istrackedphp
> }
> //and then
>
> if (isTracked(...)=='true')
>   //thing A
> else
>//thing B
>
> ---
> > var r;
> >
> > function isTracked(personcode, callback) {
> > $.get('trackstudent/istracked.php',{'personcode': personcode},
> callback);
> > }
> >
> > $(document).ready(function() {
> >
> > isTracked('10591891',function(data) {
> > r=data;
> > alert(r);
> > });
> >
> > });
> So in that case I dont have to use callback in isTracked.
> I can do the same thing in this way:
> function isTracked(personcode) {
> $.get('trackstudent/istracked.php',{'personcode': personcode},
> function(data) {
>  r=data;
>  alert(r);
>  });
> }
>
> and i still will have alert with proper value, but its not what I
> want.
> I want to get data from php file and return it from isTracked
> function. ( to do something like that: ...
> if (isTrackes(..)=='true'))
>
>
> Thanks
> Michael
>
>


[jQuery] Re: Alternative syntax?

2007-09-27 Thread Erik Beeson
You'll learn to love anonymous functions. And eventually, you'll even learn
to love closures:

(function($) {
  // do something
})(jQuery);

I guess cleanliness is relative. It looks pretty clean to me. The goal of
anonymous functions is to be able to pass around chunks of code to be
executed later. How would you propose a "cleaner" syntax look?

--Erik


On 9/26/07, A32 <[EMAIL PROTECTED]> wrote:
>
>
> I find the following example very dirty syntax:
>
> $(document).ready(function(){
> alert("Document is ready")
>
> $("a").click(function(){
> alert("Clicked");
> });
> });
>
> With all those ) and } I don't know if I'm coming or going.. Is there
> an alternate syntax I can use? Do I *have* to use the "function()" all
> the time or is there a different way? I've been away from JavaScript
> for a long time but never seen anything like that :-)
>
> If there's no way around it, does anybody know of a javascript
> preprocessor that I could use a cleaner syntax while developing?
>
> Thanks!
>
>


  1   2   3   4   5   >