[jQuery] Re: different lengths by IE and ff

2010-01-07 Thread KeeganWatkins
at first glance, you may be expecting the :hidden selector to work
differently than it actually does:

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

the original implementation, before 1.3.2, checked for either
display:none or visibility:hidden, whereas the new implementation
selects elements "...if it or its parents consumes no space in
document. CSS visibility isn't taken into account."

so, my first question would be, which version of jQuery are you using?
anything before 1.3.2 won't even return hidden inputs with the
":hidden" selector.

can you post a test page?

On Jan 7, 12:48 pm, CreativeMind  wrote:
> Hi,
> I have a dropdown which diplays a companyname with 4 hidden inputs.
> these hidden input values are set in text boxes on selected index
> change of dropdown.
> like this
>   var sourcedropdown = $(e.target).parent().parent().children(":nth-
> child(7)").children().eq(0);
>    $(sourcedropdown).append($('').val(val).html
> (sourcename).addClass('selectedval'+val));
>    var priceval=text[1];
>    $.each(priceval,function(leftval,rightval){
>
>    $(sourcedropdown).append($(' (7)").children().eq(0);
>  $(sourcedd).change(function(){
>
>                     var hiddenchildrens=$(this).children
> ("input:hidden");
>                    alert(hiddenchildrens.length);});
> }
>
> should i append the hidden inputs in some other way ?
>
> thanx,


[jQuery] Re: $.getScript results in two requests!

2009-11-25 Thread KeeganWatkins
just out of curiosity, have you checked to make sure you aren't using
the $.ajax() method (or one of its convenience methods) elsewhere? i
see in the first set of headers that the "X-Requested-With" header is
present, which is generally added by jQuery (and most other libs) when
a request is submitted via XHR. so, the first request is being
submitted via ajax, and the second request is not. is this
intentional?

also, just a note that $.getScript() is generally used to make cross-
domain calls (which are not allowed in XHR), so if the resource is on
the same domain i'd recommend scrapping the $.getScript() call and
replacing it with an $.ajax() call.

of course, as michael suggested, a test page would get us all much
closer to the answer :)

On Nov 24, 4:19 pm, Michael Geary  wrote:
> Can you post a link to a test page?
>
> Pretty hard to troubleshoot by just looking at the headers.
>
> Of course, someone will come along and troubleshoot it from the headers
> alone and prove me wrong! :-)
>
> -Mike
>
> On Tue, Nov 24, 2009 at 6:50 AM, Eric  wrote:
> > Hey there,
>
> > A $.getScript() call I am making results in two seperate requests to
> > the server. Any chance I can avoid that?
>
> > Here are the headers:
>
> > GET server.file?param1=param2 HTTP/1.1
> > Host: server
> > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; de; rv:1.8.1.20)
> > Gecko/20081217 Firefox/2.0.0.20
> > Accept: text/javascript, application/javascript, */*
> > Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
> > Accept-Encoding: gzip,deflate
> > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive: 300
> > Connection: keep-alive
> > X-Requested-With: XMLHttpRequest
> > Referer:http://server/indexfile.html
> > Cookie: (Cookie Contents)
>
> > Followed by...
>
> > GET server.file?param1=param2 HTTP/1.1
> > Host: server
> > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; de; rv:1.8.1.20)
> > Gecko/20081217 Firefox/2.0.0.20
> > Accept: text/xml,application/xml,application/xhtml+xml,text/
> > html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> > Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
> > Accept-Encoding: gzip,deflate
> > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive: 300
> > Connection: keep-alive
> > Cookie: (Cookie Contents)
>
> > The web server runs IIS6.
>
> > Thanks for your help
> > Eric


[jQuery] Re: GET id value from url in jQuery

2009-11-24 Thread KeeganWatkins
inside of the function that you pass to click(), the keyword "this"
will point to the raw DOM element that dispatched the event. so, in
your example, you need to add:

$(document).ready( function ()
{
$(".delete").click(function()
{
   // Get the ID, "this" points to the  that was clicked
   // Find the href, the parse out the
final number value
   var ref = $(this).attr("href");
   ref = ref.slice(ref.indexOf("=") + 1);
$.post("deleting_posts.php", { id:
ref }, function(data)
{
..
});
return false;
});
});


this is untested, but should be very close. hope that helps.
On Nov 24, 9:14 am, dziobacz  wrote:
> How can I take value of ID clicked link in jQuery ??
> I have links:
> delete
> delete
> delete
> .
>
> My jQuery script:
> $(document).ready( function ()
>                 {
>                         $(".delete").click(function()
>                         {
>                                 $.post("deleting_posts.php", { id: 
> WHAT_HERE_?? }, function(data)
>                                 {
>                                         ..
>                                 });
>                                 return false;
>                         });
>                 });
>
> How can I take value of ID clicked link in jQuery ??


[jQuery] Re: list bullet style

2009-11-24 Thread KeeganWatkins
i'm not sure i understand... hard-coded numbering? something like this
(?) :

HTML

1 List Item
2 List Item
3 List Item


if you are looking for a numbered list, you should be using the 
tag, although the  tag is going to have the same limitations...
you can set a background image for the numbers, or separate the
content into nested  tags, but i don't know of any way to bold
just the number otherwise... the CSS pseudo-class ":first-letter" will
target the first character, not the bullet or number.

On Nov 24, 12:10 am, dnagel  wrote:
> Not quite what I'm after...
>
> Wanted to use the LI's native numbering and be able to bold just that,
> not the content inside the LI.
>
> Right now I have spans inside the LI with hard coded numbering to get
> the bold effect.  I'm just trying to accommodate a client.
>
> Putting the spans around the inner content seems like 6 of one to
> me...
>
> Thx,
>
> D.


[jQuery] Re: list bullet style

2009-11-23 Thread KeeganWatkins
what do you mean by "snappy"? you could always just use CSS (not sure
how this questions relates to jQuery or JavaScript at all) to replace
the bullet with your own image:

HTML:

List Item 1
List Item 2
List Item 3


CSS:
ul li {list-style-type:none;background:transparent url(path/to/bold-
bullet.gif) no-repeat left center;}

as far as i know, you can't style just the bullet unless you wrap the
's content in some other tag, such as:
HTML:

List Item 1
List Item 2
List Item 3


CSS:
ul li {font-weight:bold;}
ul li span {font-weight:normal;}

but in the last example, you are adding non-semantic  tags,
which should be avoided where possible.


On Nov 21, 1:45 am, dnagel  wrote:
> Can anyone think of a snappy way to set the font to bold only on the
> bullet(decimal)?  The content of the LI should remain font-
> weight:normal


[jQuery] Re: imitate link

2009-11-20 Thread KeeganWatkins
charlie and dave are correct: you should use elements semantically to
ensure your content runs on as many platforms/devices/configurations
as possible. with that being said, there is a simple answer to your
original question:

HTML:
Home

JS:
$("#fake_link").click(function() {
window.location = "http://your.domain.com/path/to/wherever";';
});

if you don't take the advice to use  elements instead, please
Please PLEASE use  instead of .  and  elements
are long-deprecated.

On Nov 17, 10:24 pm, Dave Methvin  wrote:
> > > Can make  behave as  ?
> > Why would you not just use CSS to style an  element
> > to be bold and not underlined?
>
> Definitely the way to go. That way the link works with the keyboard
> and screen readers as well. Apps that require the mouse drive me crazy.


[jQuery] Re: show/hide div on select change

2009-11-20 Thread KeeganWatkins
also, just as a head's up... even when you store numbers as the
"value" attribute on an  tag, they are interpreted as strings
in javascript. so, from your example above, you might also consider
switching your condition to:

// Compare as string instead
if ($("#id_status").val() === '6'){
$('div.textfield1').show();
}

when you compare the two as strings using the strict equality operator
(===), your results will likely be far more predictable. hope that
helps.

On Nov 18, 2:03 pm, mtuller  wrote:
> Thanks.
>
> On Nov 18, 1:50 pm, Charlie Griefer  wrote:
>
> > You're missing a $ on this line:
>
> > ('#id_status').change(function() {
>
> > Change to:
>
> > $('#id_status').change(function() {
>
> > unsolicited word of advice... run firebug :)
>
> > On Wed, Nov 18, 2009 at 11:44 AM, mtuller  wrote:
> > > I am trying to have a div show and hide based on the value of a select
> > > list. I have looked at a number of examples, but can't seem to get it
> > > to work. Would appreciate someone taking a look at what I have and
> > > giving me any advice.
>
> > > 
> > > $(document).ready(function() {
> > >        $('div.textfield1').hide();
>
> > >        ('#id_status').change(function() {
>
> > >                if ($("#id_status").val() == 6){
> > >                        $('div.textfield1').show();
> > >                }
> > >                else{
> > >                        $('div.textfield1').hide();
> > >                }
> > >   });
> > > });
> > > 
>
> > > Status:
> > >        
> > >                New
> > >                In Review
> > >                Working On
> > >                Elevated
> > >                Approved
> > >                Deferred
> > >                Denied
> > >                Duplicate
> > >                Completed
> > >                Needs more information
> > >        
>
> > > 
> > > test
> > >    
> > >  
> > > 
>
> > --
> > Charlie Grieferhttp://charlie.griefer.com/
>
> > I have failed as much as I have succeeded. But I love my life. I love my
> > wife. And I wish you my kind of success.


[jQuery] Re: jq 1.3.2 in IE6 syntax error line 324

2009-11-20 Thread KeeganWatkins
can you post a test page? just by scanning, there isn't anything that
jumps out at me as being broken/syntactically incorrect...
just a tip, though, you can combine your selectors to make that part
more efficient:

$(function(){
$('#username, #password, #valicode').keydown(function(event){
if(event.keyCode==13){
formLogin();
}
});
});

the initial selection might take longer (to find three elements, as
opposed to just one), but in the new format you will avoid creating
three separate (but identical) closures to handle the keydown event.
hope that helps, post a test page and we can help diagnose the error.

On Nov 19, 12:43 am, viperasi  wrote:
> Either jquery-1.2.3.js or jquery-1.3.2.min.js, i got the error in
> IE6,other browsers without error.
> the code:
>
> $(function(){
>         $('#username').keydown(function(event){
>                 if(event.keyCode==13){
>                         formLogin();
>                 }
>         });
>         $('#password').keydown(function(event){
>                 if(event.keyCode==13){
>                         formLogin();
>                 }
>         });
>         $('#valicode').keydown(function(event){
>                 if(event.keyCode==13){
>                         formLogin();
>                 }
>         });
>
> });
>
> Can anyway help me please? I think it's something really simple and
> I'm just being stupid.
>
> Many thanks for reading and sorry for my poor English.


[jQuery] Re: No reaction with $('a').click(), OK with dispatchEvent(...)

2009-11-20 Thread KeeganWatkins
>> At the moment I'm not so interested in the right/smart way to write an
>>  tag. It's more interesting to me to see what the jQuery click()
>> function can and cannot do

ok, then read the source. we're trying to offer solutions to the
problem, but if you just want some info on what jQuery's click method
is capable of, it's defined on lines #2590 through #2663 in version
1.3.2.
or you can read the docs:
http://docs.jquery.com/Events/trigger
NOTE: Most of the event shortcut methods (click, hover, focus, etc)
use jQuery,event.trigger() under the hood.

On Nov 20, 5:47 am, Jon  wrote:
> Hi,
>
> I'm not quite sure what you try to show me with that $('#a3').click
> (...stuff...) below, but I can tell you what I just found out: The
> difference I've mentioned between my clickAt($('#a1')[0]) and $
> ('#a1').click(), and also with #a3, occurs in Safari and Opera, but in
> Firefox (3.0.3 and 3.5.5) my clickAt(...) does no more than $
> (...).click(). In IE7 my clickAt(...) just gives me an [object Error].
> What a mess!
>
> /Jon
>
> On Nov 20, 11:18 am, Olaf Bosch  wrote:
>
> > Jon schrieb:
>
> > > and one (#a3) that links to this Google Groups page. With the latter I
> > > observe the same difference as with #a1: my clickAt($('#a3')[0])
> > > works, but $('#a3').click() doesn't. Bug or feature?
>
> > Sorry I can't follow you. I added this to Firebug on your Testpage:
>
> > $('#a3').click( function() {
> >            return false;
> >            });
>
> > And then Click on #a3 and nothing
>
> > --
> > Viele Gr e, Olaf
>
> > ---
> > olaf.bo...@t-online.dehttp://olaf-bosch.de/http://ohorn.info/http://www.akitafreund.de/
> > ---


[jQuery] Re: What is the opposite of :checked?

2009-11-19 Thread KeeganWatkins
should also be pretty easy to roll your own :not-checked selector:

$.expr[":"]["not-checked"] = function(elem, i , m) {
// use === false to avoid undefined "checked" property
// creating false positives
return elem.checked === false;
}

On Nov 19, 3:00 pm, Charlie Griefer  wrote:
> http://docs.jquery.com/Selectors/not
>
> On Thu, Nov 19, 2009 at 12:55 PM, Atkinson, Sarah <
>
> sarah.atkin...@cookmedical.com> wrote:
> >  What is the opposite of :checked?
>
> > Is it :unchecked? Or would you use the not (!)
>
> --
> Charlie Grieferhttp://charlie.griefer.com/
>
> I have failed as much as I have succeeded. But I love my life. I love my
> wife. And I wish you my kind of success.


[jQuery] Re: No reaction with $('a').click(), OK with dispatchEvent(...)

2009-11-19 Thread KeeganWatkins
if you have to keep your JavaScript inline, you should use the onclick
attribute instead of using the "javascript:" pseudo-protocol. it was
never fully standardized, and is a lingering piece of old-school
JavaScript usage. so for your example above, use:
#a1

an even better solution (as you are already using jQuery), would be to
use the built-in binding jQuery provides, which allows you to a.) keep
your JS out of the markup, and b.) have more than one handler if you
need to:
$(function() {
$("#a1").click(function() {
// handle event here
});
});

On Nov 19, 8:21 am, Jon  wrote:
> Hi,
>
> I have an element like this: #a1
> However, when I do this: $('#a1').click(); ... then my doSomething()
> do not get called. Why?
>
> If I make my own click function, like this:
> function clickAt(targetElement) {
>         var evt = document.createEvent("HTMLEvents");
>         evt.initEvent("click", "true", "true");
>         return targetElement.dispatchEvent(evt);
>
> }
>
> ... and call it this way: clickAt($('#a1')[0]); ... then my doSomething
> () do get called.
>
> If you like, you can try it out here:  test/jq-test.html>
>
> /Jon


[jQuery] Re: IDEs of jQuery

2009-11-19 Thread KeeganWatkins
Aptana (built on Eclipse) also has great jQuery support.
http://aptana.com/

On Nov 19, 9:28 am, devilmike  wrote:
> This isn't specifically for jQuery, but NetBeans handles it extremely
> well. I use the Early Access for PHP version.
>
> Michael
>
> On Nov 19, 4:13 am, Ankur_Patel  wrote:
>
> > Can any one tell me name of jQuery IDEs... like dreamweaver use of IDE as
> > HTML,PHP,ASP,XML,CSS
>
> > Any IDE there for jQuery code so we can write codes easy & fast
>
> > Thanx


[jQuery] Re: Can I somehow see what events are binded to a DOM element?

2009-10-29 Thread KeeganWatkins
jayarjo,

you might be interested in firequery, an experimental firebug
extension that visualizes jQuery manipulations.
http://firequery.binaryage.com/

On Oct 29, 7:54 am, Bjarki  wrote:
> Using firebug:
> you can write $('selector').data('events') in the console and run it.
> then you will get all the events bound to that object.
>
> you can click the events in firebug and go to there source to view
> them.
>
> On Oct 28, 11:45 am, jayarjo  wrote:
>
> > I wonder if I can see somewhere what events are binded to a DOM
> > element (in FireBug maybe). Maybe it's obvious, but I just don't know
> > yet if it's even possible.


[jQuery] Re: Browser refresh

2009-10-21 Thread KeeganWatkins

hi lukas,

you can't specifically listen for refreshes, but you can listen for
unload events. an unload event is dispatched when:

- a link is clicked to navigate away from the page
- the window.location property is changed
- the tab is closed
- the browser window is closed
- etc

to play around with it, add this to your code:

jQuery(window).unload(function() {
alert("bye bye!");
});

note that it will fire in response to everything in the list above,
but also in response to refreshes. hope that helps.

On Oct 21, 11:38 am, lukas  wrote:
> How can I catch with Jquery a user refreshing the page with his
> browser? Thank you!


[jQuery] Re: Unexpected $(document).ready() behavior when jQuery is loaded after the page

2009-10-08 Thread KeeganWatkins

Hi Ryan,

The reason you are having problems is likely due to the way jQuery
determines DOM readiness. As noted above, if functions are passed to $
() or $(document).ready() after the DOM has loaded, they are executed
immediately. This produces the behavior you are expecting. But when
jQuery loads, it listens for native events (DOMContentLoaded, load,
etc) to determine readiness. If jQuery is injected into the page after
these events fire, I doubt the ready state is reliable.

This is reproducable with a blank page and firebug. If you create an
HTML page and open it in firebug, create  a script node and then
append it to the head, you can see that jQuery is defined, but
jQuery.isReady evaluates to false. Because the "load" and
"DOMContentLoaded" events have already fired, the logic breaks. Note
that all other bindings should work as expected. Hope that helps.

On Oct 8, 8:11 am, Ryan Crumley  wrote:
> Rob,
>
> Point taken about using onLoad for a script tag possibly not being
> supported. In this case however that part of the code is working fine.
> The issue I am having is related to jQuery being added to a page after
> the page has completed loading. When this happens ready listeners are
> never executed. If jQuery is present when the page loads then ready
> listeners are executed as expected.
>
> Ryan
>
> On Oct 8, 12:45 am, RobG  wrote:
>
>
>
> > On Oct 8, 10:04 am, Ryan Crumley  wrote:
>
> > > I am experiencing unexpected behavior using $(document).ready() on a
> > > page where I inject jQuery after the page has loaded and then attach
> > > listeners to the ready event. The ready() event is never called using
> > > Firefox and Safari however it is called using IE.
> > [...]
> > >                 function loadjquery() {
> > >                         var url = 
> > > "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
> > > jquery.js";
> > >                         var head = 
> > > document.getElementsByTagName("head")[0], done = false;
> > >                         var script = document.createElement("script");
> > >                         script.src = url;
>
> > >                         script.onload = script.onreadystatechange = 
> > > function() {
>
> > There is no onload attribute for script elements defined in HTML 4.01,
> > therefore you should not expect that a script element will fire a load
> > event. The fact that some browsers do and some don't should be enough
> > to tell you that browser behaviour is inconsistent.  You are unlikely
> > to be able to reliably fix that with script.
>
> > If you want a reliable indicator that a script has finished loading
> > and is ready for use, put a statement at the bottom like:
>
> >   var SCRIPT_LOADED = true;
>
> > --
> > Rob


[jQuery] Re: Select by containing text

2009-10-06 Thread KeeganWatkins

oops, copy/paste error. as there is no "text" method on RegExp
objects, disregard the snippet above. it should be:

// Existing "contains" filter
function (a, i, m) {
return (a.textContent || a.innerText || jQuery(a).text() ||
"").indexOf(m[3]) >= 0;
}

// New ":text-equals" filter
function (a, i, m) {
return new RegExp("^" + m[3] + "$").test(a.textContent ||
a.innerText || jQuery(a).text() || "");
}


On Oct 6, 9:50 am, KeeganWatkins  wrote:
> Hi Julijan,
>
> It sounds like what you need is a ":text-equals" filter The reason
> ":contains" fails in this case is because it does a global match. By
> anchoring the same RegExp against the beginning and end of the string,
> you should be able to select elements whose text matches exactly:
>
> // Existing "contains" filter
> function (a, i, m) {
>     return (a.textContent || a.innerText || jQuery(a).text() ||
> "").indexOf(m[3]) >= 0;
>
> }
>
> // New ":text-equals" filter
> function (a, i, m) {
>     return new RegExp("^" + m[3] + "$").text(a.textContent ||
> a.innerText || jQuery(a).text() || "");
>
> }
>
> NOTE: I haven't tested this code, but the idea itself is simple...
> instead of searching for a given string anywhere in the element's text
> content, anchor the RegExp to begin searching at the beginning of the
> element's text and match exactly through the end of the element's
> text. Hope that helps.
>
> On Oct 5, 4:20 am, "ryan.j"  wrote:
>
> > sounds like you want to .filter() the results, but that will still
> > iterate. the thing is anything that grabs a bunch of elements and
> > picks certain ones out is going to loop through them at some point.
>
> > if you wanted to do it entirely via selectors (and depending on
> > whether there is a appropriate attribute for that sort of thing in the
> > element you select) i guess you could use [attribute=xyz].
>
> > On Oct 5, 9:20 am, Julijan Andjelic 
> > wrote:
>
> > > Is there a way (selector) that would allow me to select an element by
> > > exact mach of containing text.
>
> > > example:
>
> > > 
> > >     This is some text
> > > 
>
> > > 
> > >     This
> > > 
>
> > > Lets say i want to select only the second div
> > > $("div:contains('This')")...
> > > okay, it would select it, but...it would also select the first one.
> > > I could iterate through each div and check if the text is matching but
> > > that's kinda dirty way of doing this. Is there any selector which
> > > would allow me to do this without iteration?


[jQuery] Re: Select by containing text

2009-10-06 Thread KeeganWatkins

Hi Julijan,

It sounds like what you need is a ":text-equals" filter The reason
":contains" fails in this case is because it does a global match. By
anchoring the same RegExp against the beginning and end of the string,
you should be able to select elements whose text matches exactly:

// Existing "contains" filter
function (a, i, m) {
return (a.textContent || a.innerText || jQuery(a).text() ||
"").indexOf(m[3]) >= 0;
}

// New ":text-equals" filter
function (a, i, m) {
return new RegExp("^" + m[3] + "$").text(a.textContent ||
a.innerText || jQuery(a).text() || "");
}

NOTE: I haven't tested this code, but the idea itself is simple...
instead of searching for a given string anywhere in the element's text
content, anchor the RegExp to begin searching at the beginning of the
element's text and match exactly through the end of the element's
text. Hope that helps.

On Oct 5, 4:20 am, "ryan.j"  wrote:
> sounds like you want to .filter() the results, but that will still
> iterate. the thing is anything that grabs a bunch of elements and
> picks certain ones out is going to loop through them at some point.
>
> if you wanted to do it entirely via selectors (and depending on
> whether there is a appropriate attribute for that sort of thing in the
> element you select) i guess you could use [attribute=xyz].
>
> On Oct 5, 9:20 am, Julijan Andjelic 
> wrote:
>
> > Is there a way (selector) that would allow me to select an element by
> > exact mach of containing text.
>
> > example:
>
> > 
> >     This is some text
> > 
>
> > 
> >     This
> > 
>
> > Lets say i want to select only the second div
> > $("div:contains('This')")...
> > okay, it would select it, but...it would also select the first one.
> > I could iterate through each div and check if the text is matching but
> > that's kinda dirty way of doing this. Is there any selector which
> > would allow me to do this without iteration?


[jQuery] Re: .ajax() with dataType: 'jsonp' will not use error callback if request fails

2009-10-02 Thread KeeganWatkins

I think this is a known limitation of jsonp as a technique, not a bug
with jquery itself. Jsonp works by appending a script tag to the DOM,
whose "src" attribute points to the URL you specify. The URL is
expected to wrap a json object in a function call to the function you
specify, and the returned text is evaluated using eval().. Just like
script tags that are returned in the sorce HTML, if the server doesn't
respond (or throws a 404), I don't think there is a way to determine
that through JavaScript.

$.ajax() can determine other error scenarios by inspecting the XHR
object, but jsonp doesn't use XHR. Hope that helps.

On Oct 1, 12:18 pm, mrandall  wrote:
> I'm using an .ajax() call to do a jsonp request to another domain.
> When the user is not logged in, however, the server will return a 401
> error.  Unfortunately, this causes my .ajax() call to fail _without_
> calling the error callback.  Is this a known bug?  Here is my code:
>
>       $.ajax({
>         url:      appData.API.workout.get,
>         data:     {date: App.formatDate(date)},
>         dataType: 'jsonp',
>         success:  function(json) {
>           Data =  json;
>           model.buildOrderedWorkout();
>           myCP.Workout.View.initialize();
>         },
>         error:    function(xOptions, error) {
>
>           Controller.requestError(xOptions, error);
>         }
>       });
>
> Is there a way to get this request to not fail?  I also looked at the
> jquery-jsonp plugin, but that didn't really work and did not return
> the http status codes.
>
> Thanks for your help,
> Mike


[jQuery] Re: if opera...... else

2009-09-25 Thread KeeganWatkins

hi a1anm,

if it's a CSS property, you can always determine that without relying
on the deprecated $.browser object...

$(function() {
// Check for the property you are interested in. Will be a
Boolean value
var opera = typeof $("body")[0].style["OperaOnlyCSSProp"] ===
"undefined";

if (opera) {
// do something
}
});

On Sep 22, 9:31 pm, a1anm  wrote:
> it's a css property so I'm not sure if checking to see if it is
> supported if possible.  The link you posted did the trick though.
> thanks.
>
> On Sep 22, 9:37 pm, MorningZ  wrote:
>
> > While it's recommended to look for features/support more than actual
> > browser type, jQuery.browser is still in the library
>
> >http://docs.jquery.com/Utilities/jQuery.browser
>
> > On Sep 22, 9:25 pm, a1anm  wrote:
>
> > > Hi,
>
> > > I would like to output the followin content if the browser isn't
> > > opera:
>
> > >                 
> > >                          > > onclick="homeSlide()">home
> > >                          > > onclick="aboutSlide()">about
> > >                         portfolio
> > >                          > > onclick="servicesSlide()">services > > li>
> > >                          > > onclick="contactSlide()">contact > > li>
> > >                         
>
> > > If the browser is opera I would like to output something slightly
> > > different.
>
> > > How would I do this?
>
> > > Thanks!


[jQuery] Re: validate - if "other" checked --> require input box

2009-09-25 Thread KeeganWatkins

are you using the validate plugin? i'm not familiar with it at all,
but for a simple validation like this you could do:

// DOM-ready handler
$(function() {
// Listen for "onsubmit" events for the form
$("#signupForm").submit(function() {
// Get the checkbox
var checkbox = $("#chkStatus5");
// True or false based on the checkbox
var checked = checkbox[0].checked;

// If its checked...
if (checked) {
// ...grab the textfield...
var text = $("#textfield");
// ...and its value
var val = text.val();

// If the textfield is empty...
if (val === "") {
// ...validation failed,
// so do something!
}
}
});
});

hope that helps.

On Sep 21, 8:38 pm, ripcurlksm  wrote:
> I have a "How did you hear about us?" with a series of checkboxes that is
> working great, however there is an option for "Other", where they can fill
> out their answer.
>
> I want to modify the script so if the checkbox for Other is selected, they
> are required to fill in the input box.
>
> I have this working here, but I cant get the input box to be required if
> "other" is selected:http://psylicyde.com/misc/jquery-validate/demo/test.html
> --
> View this message in 
> context:http://www.nabble.com/validate---if-%22other%22-checked---%3E-require...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Each function gives errors in IE6

2009-09-25 Thread KeeganWatkins

hey Shane,

Nick's comments above simply reinforce the need for explicit variable
declaration. ignoring the "var" keyword, even when picking names that
don't collide with properties of the window object, is a dangerous
practice. it leads to hard-to-spot bugs, scope issues, and a whole
mess of other problems.

furthermore, implicit assignment (ignoring the "var" keyword to scope
a variable globally) has some quirks in relation to overwriting
properties of the window. from an article by kangax (http://
thinkweb2.com/projects/prototype/detecting-global-variable-leaks/):

"To be more precise, undeclared assignment actually results in global
property assignment, not global variable declaration. The difference
between two is rather subtle: variable declaration creates non-
deletable property of a global object, whereas explicit or implicit
property assignment creates deletable one. Another peculiarity can be
observed in IE, where global property assignment is disallowed if
there's an element in a document with the same-named ID or NAME value.
Global variable declaration, on the other hand, quietly overwrites
existing property in cases like this. "

Effectively, outside of any other code, the statements:

top = "someValue";
var top = "someValue";

both produce a globally scoped variable named "top" with a value of
"someValue". in the first example, however, because implicit
assignment is used AND "top" is an existing property of the global
object (window in the case of the browser) IE chokes. there is a
wonderful solution that couldn't be easier to remember:

don't omit the "var" keyword. ever. :)

hope that helps!



On Sep 24, 6:58 am, Nick Fitzsimons  wrote:
> 2009/9/24 Shane Riley :
>
>
>
> > Weird double post. Found the issue. For some reason declaring the
> > variable worked. So I changed it to:
> > var  top = (parseInt($(this).height()) / 2) - 6;
>
> That's because "top" is already defined as a synonym for the top-level
> window object, and IE gets upset if you try to overwrite it.
>
> I think you'd get the same "Not implemented" error if you tried to
> assign values to the global "self", "parent", and "window" properties
> too. Assuming you're not running in a frame or an iframe, "self",
> "top", "parent", and "window" all refer to the same object. In a frame
> or iframe, "self" and "window" will refer to the framed document's
> "window", and "top" will refer to the "window" object of the very
> topmost document, while "parent" will refer to the "window" object of
> the document containing the frame, which is not the same as "top" if
> you have nested frames/iframes.
>
> Regards,
>
> Nick.
> --
> Nick Fitzsimonshttp://www.nickfitz.co.uk/


[jQuery] Re: Convert MooTools to jQuery

2009-09-25 Thread KeeganWatkins

hi GonzoDesign -

this is a straight port. i'm not that familiar with mootools, so one
aspect that may be off is the selection of elements. i'm assuming $
('europe') returns the element with an ID of "europe" but if not
you'll need to change the ported selectors. you can read up on how
jQuery implements CSS selectors at http://docs.jquery.com/Selectors if
you need to tweak the element selection.

i'm certain there is a cleaner way to handle this, but without knowing
what's going on (and in light of your request for a straight port)
i've done no other refactoring. even though your not a "javascript
person", i've included some comments to (hopefully) help explain how
the differences between the libraries are addressed. hope it helps.

CODE:
// DOM-ready handler
$(function() {

// Listen for "onkeyup" events
$("#myInput").keyup(function() {

// Store a reference to the "myInput" node.
var elem = $(this);

var max_chars = 20;
var current_value = elem.val();
var current_length = current_value.length;
var remaining_chars = max_chars - current_length;

// Store a reference to the element to update
var target = $("#europe");

if (remaining_chars <= 14) {
target.css('opacity', '3.5');
} else if (remaining_chars <= 15) {
target.css('opacity', '3');
} else if (remaining_chars <= 16) {
target.css('opacity', '0.25');
} else if (remaining_chars <= 17) {
target.css('opacity', '0.2');
} else if (remaining_chars <= 18) {
target.css('opacity', '0.15');
} else if (remaining_chars <= 19) {
target.css('opacity', '0.1');
} else {
target.css('opacity', '0.05');
}

});
});

On Sep 25, 12:15 pm, GonzoDesign 
wrote:
> I know this is sloppy code, I'm more of a HTML and CSS person than
> JavaScript person. The thing is this code does exactly what I need it
> to do. This is done with mootools and it conflicts with some other
> jQuery things going on, on the page. I would REALLY appreciate any
> help anyone could give me.
>
> This isn't the finished code implemented but if there core details of
> this code could be re-written as jQuery I can probably tailor it for
> the purpose I'm using it for.
>
> window.addEvent('domready', function() {
>         $('myInput').addEvent('keyup', function() {
>                 max_chars = 20;
>                 current_value   = $('myInput').value;
>                 current_length  = current_value.length;
>                 remaining_chars = max_chars-current_length;
>                 $('counter_number').innerHTML = remaining_chars;
>
>                 if(remaining_chars<=14){
>                         $('europe').setStyle('opacity', '3.5');
>                 }
>                 else if(remaining_chars<=15){
>                         $('europe').setStyle('opacity', '3');
>                 }
>                 else if(remaining_chars<=16){
>                         $('europe').setStyle('opacity', '0.25');
>                 }
>                 else if(remaining_chars<=17){
>                         $('europe').setStyle('opacity', '0.2');
>                 }
>                 else if(remaining_chars<=18){
>                         $('europe').setStyle('opacity', '0.15');
>                 }
>                 else if(remaining_chars<=19){
>                         $('europe').setStyle('opacity', '0.1');
>                 } else {
>                         $('europe').setStyle('opacity', '0.05');
>                 }
>         });
>
> });


[jQuery] Re: this.reset() doesn't work

2009-09-16 Thread KeeganWatkins

@Dhruva-

>> It should be $(this).reset();

That won't work. Note that reset() is a method that is available on
raw form elements in the DOM, but not on a jQuery-wrapped set.

// Example for Firebug
console.log(jQuery.fn.reset) // undefined

@pritisolanki -
You can't expect the selector engine (or your page, for that matter)
to work properly when you have several ID's that are the same. You
have three forms that all have an id="form" in your sample HTML. This
is non-compliant with W3C standards and can cause a whole mess of
problems. If you need to select them all, use the class attribute
instead.

Furthermore, you are using the name and ID attribute in a way which
contributes to what is often called the "deadly expando". You should
definitely consider avoiding ID and name attributes such as "form",
"submit", "text", etc as described in these articles ->
http://ejohn.org/blog/deadly-expandos/ and http://jibbering.com/faq/names/
. "form" as an ID doesn't directly induce this phenomena, but the
principle is the same: don't use attribute values which might conflict
with DOM properties.

Change your ID's to be unique and all should be good. For reuse, you
could create a simple plugin:
$.fn.reset = function() {
return this.each(function() {
// Check against forms, and for the reset method
if (this.tagName.toLowerCase() === "form" && this.reset) {
this.reset();
}
});
}

Usage:
$("#myForm").reset();

On Sep 16, 7:50 am, Dhruva Sagar  wrote:
> It should be $(this).reset();
> But since your using an id in the selector, that will reset only the
> particular form you want.
> If you wish to reset all the forms in the page you should do something
> similar to this :
>
> $('form').each(function(){
>    $(this).reset();
>
> });
>
> You should of course put this piece of code in the document ready function.
>
> Thanks & Regards,
> Dhruva Sagar.
>
> Pablo Picasso
> - "Computers are useless. They can only give you answers."
>
> On Wed, Sep 16, 2009 at 1:45 PM, pritisolanki  wrote:
>
> > Hi,
>
> > I am trying to reset all the form element but it is not working can
> > someone suggest the reason.
>
> >  >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > http://www.w3.org/1999/xhtml";>
> > 
> > 
> > jQuery Starterkit
>
> >  > href="screen.css" />
> > 
> > 
> > 
> > 
> > 
> > 
> > 
>
> > jQuery Starterkit
> > This page contains code to test the examples. Most of it is only
> > relevant for a example.
>
> > Some link
> > 
> > 
> > Hehehehe so think you can hide me :-p  > p>
> > 
> > 
> >        
> >                Form 1
> >                
> >        
>
> >        
> >                Form 2
> >                
> >        
>
> >        
> >                Form 3
> >                
> >                
> >        
> > 
> >        Reset!
>
> > 
> > 


[jQuery] Re: Simple/short way to bind one event to multiple objects?

2009-09-15 Thread KeeganWatkins

The change event handler can also be passed by reference, avoiding the
need for the closures

("#obj1,#obj2,#obj3").change( setupPage );


On Sep 15, 7:40 am, Mr Speaker  wrote:
> you can select multiple objects in the selector, like: $
> ("#obj1,#obj2,#obj3").change(...)
>
> On Sep 15, 7:42 am, cgp  wrote:
>
> > I have 2 or more objects that onclick(), will call the same function.
> > Right now I have the following:
>
> > 
> > $("#obj1").change( function() {
> >         setupPage();});
>
> > $("#obj2").change( function() {
> >         setupPage();});
>
> > $("#obj3").change( function() {
> >         setupPage();});
>
> > 
>
> > I was wondering if there is a way to simplify or clean up the code,
> > since they are all doing the same thing and responding to the same
> > event. This is just for refactoring reasons because my code is getting
> > too long/messy.
>
> > Thanks.


[jQuery] Re: data parameter in live

2009-09-09 Thread KeeganWatkins

Hi saqib,

The live() method doesn't allow for passing custom data to the
handler.
http://docs.jquery.com/Events/live#typefn

There are possible solutions, though. Depending on what you need to
pass, you might be able to do so by using the data() method to store
your values on an element, and then access the stored values inside
the handler executed by live(). What is the nature of the data you
need to pass?

On Sep 9, 1:36 pm, saqib  wrote:
> Hi
> I have used bind method with data parameter many times
>
> $('#mydiv').bind('click', {val:a},myfunc);
>
> but in live method there is no such thing.
>
> $('#mydiv').live('click', {val:a},myfunc);
>
> Is there a work around to do achieve the task.


[jQuery] Re: get values from a select menu then assign them to an array variable

2009-09-09 Thread KeeganWatkins

Hi runrunforest,

To elaborate on Benn's explanation, the $.each and $().each() methods
provide two arguments inside the callback you supply. The first is the
index (either an enumerated key for arrays or a string key for
objects). The second is the value (the value associated with the
current key).

The docs for $.each are here:
http://docs.jquery.com/Utilities/jQuery.each#objectcallback


On Sep 8, 11:44 am, Benn  wrote:
> i is the count for the each statement making a key for the array: for
> example the first dropdown option would have an array key/value
> pairing of '0','com1'
>
> On Sep 8, 2:06 am, runrunforest  wrote:
>
> > Owsome Benn. But i don't understand why "i" is used there ?


[jQuery] Re: Testing the first character of an H1

2009-09-03 Thread KeeganWatkins

You can always create a new selector, one that works *almost*
as :contains does. The issue in your case (as I understand it) is
that :contains does a global search, so text that is not at the
beginning is still matched. It sounds like what you need is a :begins-
with filter.
Extending the filter engine is easy:

// UNTESTED!!!
jQuery.expr[ ":" ]["begins-with"] = function(elem, index, match) {
return ( new RegExp("^" + match[3]).test( elem.textContent ||
elem.innerText || "" ));
}

To use, create a selector using that filter.
$("p:begins-with('someText')'')

Hope that helps.


On Sep 3, 3:32 am, dashard  wrote:
> Is there a way -- I've wracked my brains on this but I'm a jQuery
> novice -- to determine what the first letter of a selector is?
>
> For example, if the very first letter of a paragraph is a quote (or a
> ‘ , or a “ , etc) I would like to apply a negative text-
> indent to the found paragraph so as to replicate "hanging quotes" that
> are commonplace in the print world.
>
> The code I've come up with is:
>
>         $("p:contains(“), h1:contains(“), h2:contains(“)").css({'text-
> indent':'-0.3em'});
>
> but this grabs any p or h1 or h2 that *contains* an opening curly
> quote; not what I'm looking for. I need it to select paragraphs that
> *start* with the opening curly quote.
>
> Incidentally, I could not get this to work when I was searching for     $
> ("p:contains(\&\#8220\;)... but it worked when I entered an actual
> opening curly quote in the search (as above top). I tried both single
> and double escapes too.
>
> Any help would be greatly appreciated. I would love to roll this out
> as a plugin, since it seems simple and really enhances the look of a
> page of text to have the opening quotes hanging properly.


[jQuery] Re: How to detect window is scroll or not using window.scrollTo()

2009-09-01 Thread KeeganWatkins

Here's the docs:
http://docs.jquery.com/CSS/scrollTop

On Sep 1, 9:34 am, KeeganWatkins  wrote:
> @Rupak,
>
> I'm not sure if this answers your question, but all wrapped sets have
> a scrollTop() method that can be used to retrieve or set the scrollTop
> value. For example, to determine how far down the page has been
> scrolled, you can use:
> var top = jQuery(window).scrollTop();
>
> The same method can be used to set the scrollTop value:
> // Scroll the root elements
> jQuery("html, body").scrollTop(100);
>
> By using the $().scrollTop() method, you should be able to get and/or
> set the scroll values on most elements. Hope that helps!
>
> On Sep 1, 8:58 am, Karl Swedberg  wrote:
>
> > Hi Rupak,
>
> > Not sure what what you mean by "window is scroll" and the question  
> > seems like more related to general JavaScript than jQuery in  
> > particular, but if you're trying to determine whether the window has  
> > been scrolled down, you can use the scrollTop property. For Firefox  
> > and IE, you'd check it as a property of document.documentElement; in  
> > Safari, as a property of document.body. This should find it for you:
>
> > var windowScrollTop = document.documentElement.scrollTop ||  
> > document.body.ScrollTop;
> > if (windowScrollTop > 0) {
> >    // do something
>
> > }
>
> > Note: the scrollTop property is part of IE's DHTML object model, not a  
> > w3c spec. Gecko and Webkit seem to implement it, so you should be  
> > relatively safe, but your mileage may vary on obscure browsers.
>
> > --Karl
>
> > 
> > Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> > On Sep 1, 2009, at 8:27 AM, Rupak wrote:
>
> > > Hi all,
>
> > > Is there a way to detect whether window is scroll or not .I am using
> > > window.scrollTo() function.
>
> > > Thanks
> > > Rupak


[jQuery] Re: How to detect window is scroll or not using window.scrollTo()

2009-09-01 Thread KeeganWatkins

@Rupak,

I'm not sure if this answers your question, but all wrapped sets have
a scrollTop() method that can be used to retrieve or set the scrollTop
value. For example, to determine how far down the page has been
scrolled, you can use:
var top = jQuery(window).scrollTop();

The same method can be used to set the scrollTop value:
// Scroll the root elements
jQuery("html, body").scrollTop(100);

By using the $().scrollTop() method, you should be able to get and/or
set the scroll values on most elements. Hope that helps!

On Sep 1, 8:58 am, Karl Swedberg  wrote:
> Hi Rupak,
>
> Not sure what what you mean by "window is scroll" and the question  
> seems like more related to general JavaScript than jQuery in  
> particular, but if you're trying to determine whether the window has  
> been scrolled down, you can use the scrollTop property. For Firefox  
> and IE, you'd check it as a property of document.documentElement; in  
> Safari, as a property of document.body. This should find it for you:
>
> var windowScrollTop = document.documentElement.scrollTop ||  
> document.body.ScrollTop;
> if (windowScrollTop > 0) {
>    // do something
>
> }
>
> Note: the scrollTop property is part of IE's DHTML object model, not a  
> w3c spec. Gecko and Webkit seem to implement it, so you should be  
> relatively safe, but your mileage may vary on obscure browsers.
>
> --Karl
>
> 
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Sep 1, 2009, at 8:27 AM, Rupak wrote:
>
>
>
> > Hi all,
>
> > Is there a way to detect whether window is scroll or not .I am using
> > window.scrollTo() function.
>
> > Thanks
> > Rupak


[jQuery] Re: Settimeout on Function

2009-08-31 Thread KeeganWatkins

So, it's just a simple issue with scope. Try this instead (which was
working when applied via FireBug to your demo page:

$(document).ready(function(){
$("#barcode span").hover(
  function () {
$(this).addClass("barover");
  },
  function () {
   // Store span reference
  var span = $(this);
   setTimeout(function() {
span.removeClass("barover");
  }, 2000);
  }
);
  });

Note that the timer used here is 2000 milliseconds (2 seconds), so
you'll likely have to tweak that value to fit your needs. Hope that
helps.
On Aug 30, 7:22 pm, a1anm  wrote:
> Hi,
>
> I tried this but it didn't work.  It resulted in the class not being
> removed at all.  You can see here:
>
> http://www.toomanydesigns.com/test/noflash/
>
> On Aug 30, 11:20 am, KeeganWatkins  wrote:
>
> > The basic syntax for delaying a function using setTimeout is this:
>
> > setTimeout(function() {
> >     // ...code here executes when the timeout is complete
>
> > }, 2000 /* Length of timeout, in milliseconds */);
>
> > so for your example, something like this should work:
>
> >  $(document).ready(function(){
>
> >     $("#barcode span").hover(
> >       function () {
> >                 $(this).addClass("barover");
> >       },
> >       function () {
> >            setTimeout(function() {
> >                 $(this).removeClass("barover");
> >           }, 2000);
> >       }
> >     );
> >   });
>
> > On Aug 30, 9:49 am, a1anm  wrote:
>
> > > Hi,
>
> > > I have this code:
>
> > >  $(document).ready(function(){
>
> > >     $("#barcode span").hover(
> > >       function () {
> > >                 $(this).addClass("barover");
> > >       },
> > >       function () {
> > >                 $(this).removeClass("barover");
> > >       }
> > >     );
> > >   });
>
> > > I would like to add a timeout so that the removeClass gets delayed for
> > > a specified amount of time.  Any ideas how to add a settimeout to
> > > this?
>
> > > Thanks!


[jQuery] Re: Settimeout on Function

2009-08-30 Thread KeeganWatkins

The basic syntax for delaying a function using setTimeout is this:

setTimeout(function() {
// ...code here executes when the timeout is complete
}, 2000 /* Length of timeout, in milliseconds */);

so for your example, something like this should work:

 $(document).ready(function(){

$("#barcode span").hover(
  function () {
$(this).addClass("barover");
  },
  function () {
   setTimeout(function() {
$(this).removeClass("barover");
  }, 2000);
  }
);
  });

On Aug 30, 9:49 am, a1anm  wrote:
> Hi,
>
> I have this code:
>
>  $(document).ready(function(){
>
>     $("#barcode span").hover(
>       function () {
>                 $(this).addClass("barover");
>       },
>       function () {
>                 $(this).removeClass("barover");
>       }
>     );
>   });
>
> I would like to add a timeout so that the removeClass gets delayed for
> a specified amount of time.  Any ideas how to add a settimeout to
> this?
>
> Thanks!


[jQuery] Re: Reading text value on element

2009-08-28 Thread KeeganWatkins

Jesper, in your first example, you were passing the string "this", not
the keyword. The keyword "this" is a reference to the button (in that
case), and the string "this" is useless for that purpose. In your
second example, you are creating a wrapped set, accessing the first
element in that set, and then passing that first element in to a new
wrapped set, which is effectively twice the processing that you need
to access those elements. Try this instead:

$("button.primary").each(function(){
  // To access the text
  var button = $(this);
  var text = button.text();

  // To set new text
  button.text("Some new foo bar text");
});

$(...).html() returns the innerHTML, while $(...).text() returns the
text content. As you have no nested tags inside your buttons
(according to your sample code), you should be able to use .text()
without any issues.

Hope that helps.

On Aug 27, 1:35 pm, Jesper Rønn-Jensen  wrote:
> Solution:
>
> $($("button.primary")[0]).text()
>
> -- or should we call this a workaround ?
>
> Why will I have to wrap the element in another jQuery function call?
>
> /Jesper
>
> On Aug 27, 5:26 pm, Jesper Rønn-Jensen  wrote:
>
> > I'm trying to read (and then change) the text on two buttons in my
> > user interface:
>
> > Approve selected
> > Reject selected
>
> > Now depending on how many checkboxes (elsewhere) are selected, I want
> > to change the text to something like "Approve 4 selected"
>
> > I'm tried in vain to acess:
> > $("button.primary").each(function(){
> >   console.log( $('this').text() );//fails
> >   console.log( $('this').html() );//fails
>
> > });
>
> > and for completeness sake I also tried $(this).value -- but of course
> > it returns the .value attribute of the button.
>
> > 2 questions:
>
> > How do I access the text and change it?
> > And where is that documented -- link wanted :)
>
> > Any help appreciated :)
>
> > /Jesper Rønn-Jensenwww.justaddwater.dk


[jQuery] Re: innerWidth doesn't measure scrollbars in Safari/Chrome

2009-08-27 Thread KeeganWatkins

@tinker - first, as BabBna suggested, don't hijack someone else's
post! :)

second, in relation to your question, here is what you need:

var scripts = document.getElementsByTagName("script");
var thisScript = scripts[scripts.length - 1];

after running this code, the variable "thisScript" is now a reference
to the script that contains the code above. the way this works is like
this: first, grab a reference to ALL the scripts on the page. then,
knowing the JS parse order, you can be sure that the last node in the
array of script nodes is the current script. from there, you can treat
it like any other node. for example, to get a query string that was
passed to your script, add the following code to the snippet above:

var source = thisScript.src;
var query = source.slice(source.indexOf("?") + 1, source.length);

at this point, the variable "query" will now be a string representing
the query string that was passed to the script.

@BaBna - unfortunately, i can't be of much help to your question.
sorry to continue threading on an unrelated topic, but hopefully this
solves tinker's issue and you won't get any more unrelated feedback.

On Aug 27, 6:04 am, BaBna  wrote:
> Rechanging the subject to its original title...
>
> On Aug 27, 12:02 pm, BaBna  wrote:
>
> > First, why did you change the title of my post and added your
> > unrelated question there?
>
> > Second, in PHP, PHP_SELF doesn't send the name of the actual php
> > script in which it is called but the page running in the browser, i.e.
> > if you call PHP_SELF from a file included in your index.php, PHP_SELF
> > will return index.php, and not the name of the file you are actually
> > calling it from. I think it's the same in JavaScript, you can't get
> > the name of the actual JS file (I am not 100% sure), but you can get
> > the URL of the page with document.location.href.
>
> > On Aug 26, 2:06 pm, tinker  wrote:
>
> > > Hi there,
>
> > > I wish to get the path and filename of the current running js file  
> > > itself. I thought there must be the similar way just like php's  
> > > $_SERVER['PHP_SELF'] does but I cannot find any clue. As you know,  
> > > 'location' returns path and filename of html file not js file. Anyone  
> > > knows how to do that? I have been stuck by this question for weeks. I  
> > > wait for good answer. Thank you.
>
> > > Tink


[jQuery] Re: $.inArray optimisation

2009-08-25 Thread KeeganWatkins

@morningz - it wouldn't surprise me. Nonetheless, if it were up to me,
(which it's not), jQuery wouldn't use it until it becomes
standardized. Prototype, MooTools and other competitors all augment
native data types, and it drives me nuts. Respect for the environment
is one of the features of jQuery that I enjoy the most. My point is
this: the only benefit of checking for indexOf would be to add it if
needed, which jQuery *generally* doesn't do. I can't see forking the
code for $.inArray being worthwhile unless it brought serious speed
improvements.

On Aug 25, 9:15 am, MorningZ  wrote:
> "IMO, it doesn't belong in the core"
>
> I think I read somewhere that a check for that usage will be in 1.3.3
> core, but damned if I can find where I saw that stated
>
> On Aug 25, 9:59 am, KeeganWatkins  wrote:
>
>
>
> > it does not work in every browser. the purpose of jQuery and similar
> > libraries is to streamline development and create a (mostly)
> > consistent foundation to build on, regardless of browser. if you're
> > interested in gaining some performance, or just using the latest JS
> > features, i'd suggest implementing this yourself. IMO, it doesn't
> > belong in the core, but it would be easy to add.
>
> > something like this:
> > if (Array.prototype.indexOf) {
> >     $.inArray = function(elem, array) {
> >         return array.indexOf(elem);
>
> > }
>
> > because $.inArray is already a part of the core, you'd just be
> > replacing it where the native indexOf method exists on Arrays.
> > otherwise, you'd just be using the standard implementation. hope that
> > helps.
>
> > On Aug 24, 12:28 pm, "Cesar Sanz"  wrote:
>
> > > Does it works for every browser?
>
> > > - Original Message -
> > > From: "gurdiga" 
> > > To: "jQuery (English)" 
> > > Sent: Sunday, August 23, 2009 1:07 PM
> > > Subject: [jQuery] $.inArray optimisation
>
> > > > Hello,
>
> > > > The $.inArray function is defined in
> > > >http://jqueryjs.googlecode.com/svn/trunk/jquery/src/core.js
> > > > as:
>
> > > > inArray: function( elem, array ) {
> > > > for ( var i = 0, length = array.length; i < length; i++ ) {
> > > > if ( array[ i ] === elem ) {
> > > > return i;
> > > > }
> > > > }
>
> > > > return -1;
> > > > },
>
> > > > I'm wondering: would it be possible to take advantage of the built-in
> > > > indexOf method of the Array present in FF Javascript engines? Im
> > > > thinking of something like:
>
> > > >    if (typeof Array.prototype.indexOf === 'function') {
> > > >        return array.indexOf(elem);
> > > >    }
>
> > > > What do you think?


[jQuery] Re: $.inArray optimisation

2009-08-25 Thread KeeganWatkins

it does not work in every browser. the purpose of jQuery and similar
libraries is to streamline development and create a (mostly)
consistent foundation to build on, regardless of browser. if you're
interested in gaining some performance, or just using the latest JS
features, i'd suggest implementing this yourself. IMO, it doesn't
belong in the core, but it would be easy to add.

something like this:
if (Array.prototype.indexOf) {
$.inArray = function(elem, array) {
return array.indexOf(elem);
}

because $.inArray is already a part of the core, you'd just be
replacing it where the native indexOf method exists on Arrays.
otherwise, you'd just be using the standard implementation. hope that
helps.

On Aug 24, 12:28 pm, "Cesar Sanz"  wrote:
> Does it works for every browser?
>
> - Original Message -
> From: "gurdiga" 
> To: "jQuery (English)" 
> Sent: Sunday, August 23, 2009 1:07 PM
> Subject: [jQuery] $.inArray optimisation
>
> > Hello,
>
> > The $.inArray function is defined in
> >http://jqueryjs.googlecode.com/svn/trunk/jquery/src/core.js
> > as:
>
> > inArray: function( elem, array ) {
> > for ( var i = 0, length = array.length; i < length; i++ ) {
> > if ( array[ i ] === elem ) {
> > return i;
> > }
> > }
>
> > return -1;
> > },
>
> > I'm wondering: would it be possible to take advantage of the built-in
> > indexOf method of the Array present in FF Javascript engines? Im
> > thinking of something like:
>
> >    if (typeof Array.prototype.indexOf === 'function') {
> >        return array.indexOf(elem);
> >    }
>
> > What do you think?


[jQuery] Re: Safest way to test is a variable is a jQuery object?

2009-08-24 Thread KeeganWatkins

have you considered just checking for a jQuery method? seems like that
would be the cleanest, least intrusive way of doing your check, for
example:

 function get_object_from_id(variable)
{
// if the param has a "attr" property (which jQuery
objects do,
// but raw DOM nodes don't), use that. Otherwise,
assume
// an ID was passed and return the wrapped set
return variable.attr ? variable : jQuery("#" +
variable);
};

NOTE: if you passed in a different type of object, and it contained a
"attr" property (or whatever jQuery method used for checking), this
would fall apart. However, if you know the param will either be a raw
DOM node OR a jQuery object, this should work fine.

On Aug 23, 5:53 pm, RyanZec  wrote:
> Well I think I am going to be going with a function as that was my
> first instinct.
>
> I see where your going with what you have however that would cause
> some issue if say an int or JSON object is passed as it is going to
> return that instead of an expected jQuery object.  The code I end up
> having is:
>
>         function get_object_from_id(variable)
>         {
>                 if(typeof variable == 'string')
>                 {
>                         variable = $('#' + variable);
>                 }
>                 else if(variable instanceof jQuery)
>                 {
>                         //already a jQuery object so we need to do nothing
>                 }
>                 else
>                 {
>                         //error code
>                 }
>
>                 return variable;
>         };
>
> Not sure how to handle the error (whether to throw an exception or
> just return null or what not) but this way I can handle it if
> something else is passed besides a string or jQuery object.
>
> And even tho I doubt the jQuery object are going to stop being an
> instance of jQuery any time soon, if it does, I have one location to
> change my code.
>
> Thanks for you advance.
>
> On Aug 23, 4:30 pm, "Michael Geary"  wrote:
>
> > If all you need to do is distinguish a string from a jQuery object, and you
> > want to insure that future revisions of jQuery will never break your code, I
> > would just test for the string.
>
> > I'd also put the logic in a function even if you only use it in one place,
> > e.g.
>
> >     // Return a jQuery object given either a string id or
> >     // an existing jQuery object or DOM element
> >     function $fromID( id ) {
> >         if( typeof id == 'string' ) id = '#' + id;
> >         return $(id);
> >     }
>
> > And then code:
>
> >     var $form = $fromID(form);
>
> > -Mike
>
> > > From: Eridius
>
> > > I am wondering what is the safest way to test if a variable
> > > is a jQuery object.  I am building a function where I want to
> > > be able to pass in either the id of the form or the form
> > > object itself.  The current way I am doing this is
>
> > > var $form = (form instanceof jQuery ? form : $('#' + form));
>
> > > Is this the safest way that is not likely to change?  Would I
> > > be better offer wrapping this functionality into a function
> > > all by itself so incase this does change, I only need it to
> > > change in one spot (plan on building a complete UI type framework)?


[jQuery] Re: Checkbox perpetually marked as checked

2009-08-21 Thread KeeganWatkins

Jon is correct... you are using an assignment operator in place of an
equality operator. the code you have above executes to mean:

// this isn't a test for the checkbox's state, it just sets it to true
if (document.getElementById("ownCheck").checked = true)
ownerCheck = true;
else
ownerCheck = false;

i think what you are trying to achieve could be simpler, such as:

function GetStoryPoints() {

// both ownerCheck and creatorCheck will be true or false,
depending
// on the state of the checkbox
var ownerCheck = document.getElementById
("ownCheck").checked;
var creatorCheck = (document.getElementById
("createCheck").checked;

if (ownerCheck && creatorCheck) {
$.post('/StoryPoint/ListSpecific?retrieveOwned=' +
ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
("#UserList > option:selected").attr("value"), null, function(data) {
$("#storyPointDetail").html(data);
}, "html");
}
else if (ownerCheck && !creatorCheck) {
$.post('/StoryPoint/ListSpecific?retrieveOwned=' +
ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
("#UserList > option:selected").attr("value"), null, function(data) {
$("#storyPointDetail").html(data);
}, "html");
}
else if (!ownerCheck && creatorCheck) {
$.post('/StoryPoint/ListSpecific?retrieveOwned=' +
ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
("#UserList > option:selected").attr("value"), null, function(data) {
$("#storyPointDetail").html(data);
}, "html");
}
}

On Aug 20, 11:39 am, Jon Banner  wrote:
> double == in your if statements might do the job.
>
> 2009/8/19 Nick Moy 
>
>
>
> > When the if else statements are removed, they are not perpetually
> > checked.
>
> > On Aug 19, 4:34 pm, labbit  wrote:
> > > Hello,
>
> > > I'm trying to write an if else statement in javascript so that when a
> > > check box is checked, a table will appear, and when it is checked
> > > again, another box will appear.  However, the checkbox is constantly
> > > marked as checked, and I do not know why.  I did not set any checked
> > > attritube to false or true.  What gives?
>
> > > function GetStoryPoints() {
> > >             var ownerCheck;
> > >             var creatorCheck;
>
> > >             if (document.getElementById("ownCheck").checked = true)
> > >                 ownerCheck = true;
> > >             else
> > >                 ownerCheck = false;
>
> > >             if (document.getElementById("createCheck").checked = true)
> > >                 creatorCheck = true;
> > >             else
> > >                 creatorCheck = false;
>
> > >             if (ownerCheck && creatorCheck) {
> > >                 $.post('/StoryPoint/ListSpecific?retrieveOwned=' +
> > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
> > > ("#UserList > option:selected").attr("value"), null, function(data) {
> > >                     $("#storyPointDetail").html(data);
> > >                 }, "html");
> > >             }
> > >             else if (ownerCheck && !creatorCheck) {
> > >                 $.post('/StoryPoint/ListSpecific?retrieveOwned=' +
> > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
> > > ("#UserList > option:selected").attr("value"), null, function(data) {
> > >                     $("#storyPointDetail").html(data);
> > >                 }, "html");
> > >             }
> > >             else if (!ownerCheck && creatorCheck) {
> > >                 $.post('/StoryPoint/ListSpecific?retrieveOwned=' +
> > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $
> > > ("#UserList > option:selected").attr("value"), null, function(data) {
> > >                     $("#storyPointDetail").html(data);
> > >                 }, "html");
> > >             }
> > >         }


[jQuery] Re: how to get back the DOM element as HTML source

2009-08-21 Thread KeeganWatkins

i wrote a really simple plugin for this, as i frequently have the same
use case:

jQuery.fn.outerHTML = function() {
return jQuery("").append( jQuery(this[0]).clone() ).html();
}

so that i could call it on any element, such as:

$("#fooID").outerHTML();

On Aug 19, 9:55 am, John  wrote:
> That works. Really appreciate your help. -John
>
> On Aug 18, 7:48 pm, mkmanning  wrote:
>
> > outerHTML is an IE addition to the DOM and not supported by Firefox.
> > If you want to get it with jQuery just append the element to a div and
> > get itshtml():
>
> > $('').append( $("table:first").clone() ).html()
>
> > On Aug 18, 4:37 pm, Jules  wrote:
>
> > > Use DHTML property.
>
> > > $("table:first")[0].outerHTML
>
> > > On Aug 19, 12:36 am, John  wrote:
>
> > > > Thanks, Anurag. Let me rephrase my question. For example, I can use
> > > > the following jQuery
> > > > to get thehtmlsourceof a table element
>
> > > > $("table:first").html()
>
> > > > The returnedhtmlsourcedoes not include the table itself, I like to
> > > > see thehtmlsourcestarting
> > > > from the table, for example,
>
> > > > 
> > > > ..
> > > > 
>
> > > > Is there any jQuery function for this? If not, how do I implement
> > > > this?
>
> > > > Thanks in advance,
>
> > > > John
> > > > On Aug 18, 2:06 am, anurag pal  wrote:
>
> > > > > Hi John,
>
> > > > > After setting thehtmlby usinghtmlmethod you have to bind the DOM
> > > > > elements using bind method.
>
> > > > > Example:
> > > > > 
> > > > >     $(".pge").bind("click", function(e){
> > > > >         var options = {};
> > > > >           $.ajax({
> > > > >                     url: "data_retrieval.php",
> > > > >                     cache: false,
> > > > >                     type: "GET",
> > > > >                       data: ({id : this.getAttribute('id')}),
>
> > > > >                     success: function(html){
> > > > >                         $("#slacker_detail_view").html(html);
> > > > >                         $('#slacker_detail_view').show('blind', 
> > > > > options,
> > > > > 1500);
> > > > >                     }
> > > > >                 });
> > > > >         });
> > > > > 
>
> > > > > Regards,
> > > > > Anurag Pal
>
> > > > > On Tue, Aug 18, 2009 at 7:40 AM, John  
> > > > > wrote:
>
> > > > > > Hi,
>
> > > > > > How do I get back the DOM element asHTMLsourceusing jQuery? Thehtml
> > > > > > () method only returns the innerHTML and it does not include the UI
> > > > > > element itself. But I am more interested in converting the UI 
> > > > > > element
> > > > > > itself toHTML.
>
> > > > > > Thanks in advance,
>
> > > > > > Jian


[jQuery] Re: FF processes this line fine; IE doesn't...why?

2009-08-16 Thread KeeganWatkins

Can you be sure that the response isn't being cached in IE? Even if
the .cfm response is changing, you might try to bust the cache with a
semi-random query string, i.e:

var path = '../components/propertiesDisplay.cfm?' + (new
Date).getMilliseconds();
$("#hiddenResult").load(path, null, initPagination);

On Aug 16, 2:55 pm, "Rick Faircloth"  wrote:
> Thoughts on this anyone?
>
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> Behalf Of Rick Faircloth
> Sent: Saturday, August 15, 2009 8:10 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] FF processes this line fine; IE doesn't...why?
>
> Does IE have a problem with the .load function?
>
> FF processes this line without problem.IE just seems to reload the same
>
> content that was on the screen before this line is run.
>
> $('#hiddenresult').load('../components/propertiesDisplay.cfm', null,
> initPagination);
>
> I've verified that the content of propertiesDisplay.cfm is, indeed, changing
> with
>
> each search that is run (running a search is what produces the results that
> are output
>
> to propertiesDisplay.cfm as HTML).
>
> I thought perhaps IE (7 & 8) might have a problem with .load.
>
> Thoughts anyone?
>
> --- -
> --
>
> "Ninety percent of the politicians give the other ten percent a bad
> reputation."  - Henry Kissinger


[jQuery] Re: Access denied when calling webservice method using jquery

2009-08-14 Thread KeeganWatkins

can you post some code? it's hard to offer suggestions with nothing
more than an error code to analyze...

although I'd bet you're calling your webservice via Ajax, and that the
service is not on the same domain. if this is the case, you'll need to
either: a) move the service to the same domain as the calling page, or
b) use JSONP (not Ajax) to call the webservice.


On Aug 13, 5:01 am, dinesh  wrote:
> Hi All...
>
> I want to call C# method from jquery. So, I placed those methods in
> webservice and trying to call from jquery. But, it is giving an error
> as shown below:
>
> Access to restricted URI denied" code: "1012
>
> This is seen from the Firebug console.
> Could any one help me?
>
> -Thanks


[jQuery] Re: Regular Expression validation

2009-08-08 Thread KeeganWatkins

With all due respect, I think karl's solution is somewhat less than
elegant, and could be improved by refactoring to:

// test for anything but numbers
var isValid = /[^\d]/g.test(textareaValString);

if (isValid) {
// proceed with confidence
} else {
// note to user: no numbers allowed!
}

On Aug 8, 11:13 pm, Karl Swedberg  wrote:
> On Aug 7, 2009, at 2:53 PM, Michael Lawson wrote:
>
> > yes, you can grab the value of the textbox and match it against a  
> > regular expression
> > var reg = new RegExp("/[a-zA-Z]/");
> > if(reg.test("string"))
> > {
> > return "valid";
> > }
> > else
> > {
> > return "not valid";
> > }
>
> Hey Michael,
>
> I don't think that regular expression is going to work. If you're  
> using a regular expression constructor method, as opposed to a  
> literal, you shouldn't use the slashes. Even without the slashes, that  
> test will always return true as long as the string has one upper or  
> lower case letter from a to z.
>
> The OP wanted to disallow numbers, so this should do it:
>
> if ( !(/\d/).test("string") ) {
>    return 'valid';} else {
>
>    return 'not valid';
>
> }
>
> --Karl
>
> 
> Karl Swedbergwww.englishrules.comwww.learningjquery.com


[jQuery] Re: Checkbox behaviour

2009-08-08 Thread KeeganWatkins

In general, form selections will persist when the page is refreshed.
If you add a random query string like "?foo=bar", you should see your
selections reset.

In regards to james' comments above, I think it would be far cleaner
to reset the form before the page unloads. This is a simple task:

$(window).unload(function() {
$("form").each(function() {
   this.reset() // call reset on the raw node
});
});


On Aug 7, 7:38 pm, James  wrote:
> You can have as many document ready checks as you want. I'd like to
> keep things organized by only having one though.
> As for the checkbox being selected by default when the page loads, you
> can do either of two things:
> 1) run the function on page load that checks for the checkbox and do
> any changes
> 2) or run a code to that unchecks the checkbox on page load so that
> it's always unchecked on page load.
>
> On Aug 7, 5:18 am, Samuurai  wrote:
>
>
>
> > Sorry Johnathan, I sent a seperate reply, but it never came through.
>
> > Thanks for your input.. My question about it was... is it bad practice
> > to have more than one $(document.ready(function(){}) scripts, or can I
> > have multiple?
>
> > Cheers,
>
> > Beren
>
> > On Aug 7, 1:43 pm, "Jonathan Vanherpe (T & T NV)" 
> > wrote:
>
> > > You'll have to run the whole function block within
> > > $("#show_resolve").click() on load (ie. put it somewhere in
> > > $(document).ready(function(){}).
>
> > > Make it a seperate function so you can avoid copy/pasting the whole thing
>
> > > Jonathan
>
> > > Samuurai wrote:
> > > > Hi,
>
> > > > This is my first little foray into JQuery, so far i'm impressed,
> > > > having had very little JS experience, I was able to create the result
> > > > I wanted very qucikly and easily!
>
> > > > However, I'm having one little niggle...
>
> > > > Here's my code:
> > > > [code]
> > > >                    $(document).ready(function(){
> > > >                                    
> > > > $(".submit_problem_form_right").css("visibility","hidden");
> > > >                                    
> > > > $("#left_submit").css("visibility","visible");
> > > >                                    $("#show_resolve").click(function () 
> > > > {
> > > >                                    if 
> > > > ($("#show_resolve").is(":checked"))
> > > >                                    {
> > > >                                            
> > > > $(".submit_problem_form_right").css("visibility","visible");
> > > >                                            
> > > > $("#left_submit").css("visibility","hidden");
> > > >                                    }
> > > >                                    else
> > > >                                    {
> > > >                                            
> > > > $(".submit_problem_form_right").css("visibility","hidden");
> > > >                                            
> > > > $("#left_submit").css("visibility","visible");
> > > >                                    }
> > > >                            });
> > > >                    });
> > > > [/code]
>
> > > > This works fine.. ticking the checkbox shows and hides the div.
> > > > However, if I check the checkbox and refresh the page, the checkbox
> > > > remains ticked, but the div is hidden.
>
> > > > Any ideas how I can make it work reliably?
>
> > > --
> > > Jonathan Vanherpe - Tallieu & Tallieu NV - jonat...@tnt.be


[jQuery] Re: Can I catch the property of CSS filter?

2009-07-10 Thread KeeganWatkins

you'll need to use a regular expression to get what it is that you are
looking for...

something like this might work:


// get the full string
var filterString = $('img').css('filter');
// get the src='aa.png') piece
var filterSource = filterString.replace
("progid:DXImageTransform.Microsoft.AlphaImageLoader(", "");
// remove the trailing ")" character
filterSource = filterSource.replace(")", "")


note that this is a quick and dirty approach. in production, you'd
want to write a matching regexp sequence or something a little more
sophisticated. but hopefully this will get you started. cheers.

On Jul 8, 3:33 am, "David .Wu"  wrote:
> the image is like
> 
>
> $('img').css('filter') will get
> progid:DXImageTransform.Microsoft.AlphaImageLoader(src='aa.png')
>
> Can I get the aa.png directly?


[jQuery] Re: img src attribute after append(), html()...

2009-07-10 Thread KeeganWatkins

jQuery isn't actually changing your "href" attribute, the browser
is... when you use relative paths in links (and some other elements as
well) the browser automatically appends the domain. if you need
something else, either change your relative paths to mirror something
that works for you, or simply use absolute paths.

On Jul 8, 12:15 pm, Ralph Whitbeck  wrote:
> Is this in IE?
>
> On Wed, Jul 8, 2009 at 12:41 PM, rinse_my_phonebook
> wrote:
>
>
>
> > When I call
> > $('#mydiv').append('');
>
> > I get
> > 
> >  http://localhost:53072/pathtocurrentpage/a/b/
> > image.jpg " />
> > 
> > 
>
> > Which is not what I want.
>
> > Can anyone tell me why I get this or even how I can stop jquery from
> > changing my src attribute?
>
> > Thanks in advance.


[jQuery] Re: img src attribute after append(), html()...

2009-07-10 Thread KeeganWatkins

oops, not "href" attribute, as its an image. still holds true though.

On Jul 10, 1:00 pm, KeeganWatkins  wrote:
> jQuery isn't actually changing your "href" attribute, the browser
> is... when you use relative paths in links (and some other elements as
> well) the browser automatically appends the domain. if you need
> something else, either change your relative paths to mirror something
> that works for you, or simply use absolute paths.
>
> On Jul 8, 12:15 pm, Ralph Whitbeck  wrote:
>
> > Is this in IE?
>
> > On Wed, Jul 8, 2009 at 12:41 PM, rinse_my_phonebook
> > wrote:
>
> > > When I call
> > > $('#mydiv').append('');
>
> > > I get
> > > 
> > >  http://localhost:53072/pathtocurrentpage/a/b/
> > > image.jpg <http://localhost:53072/pathtocurrentpage/a/b/%0Aimage.jpg>" />
> > > 
> > > 
>
> > > Which is not what I want.
>
> > > Can anyone tell me why I get this or even how I can stop jquery from
> > > changing my src attribute?
>
> > > Thanks in advance.


[jQuery] Re: save ajax query to global variable

2009-07-10 Thread KeeganWatkins

BaBna is correct, the alert is firing before the response has come
back, try adding the alert inside the callback. however, i would not
recommend removing the "var" keyword. as it is now, you have:

 
 var tb1=[];
 $(document).ready(function() {
// code here
});
 

because "tb1" is being defined outside of any other functions, it is
already globally scoped. removing the "var" keyword isn't going to
change the scope (as its already where it should be if you need global
access). if you ever need to force a variable to be globally scoped,
NEVER omit the "var" keyword, as it can lead to some very difficult-to-
spot bugs. anytime you need to expose a variable globally you should
simply attach it to the window object (which is where the global scope
lives when Javascript runs in the browser).

DON'T DO THIS!!! :

 
 myGlobalVar = "foo"; // "var" keyword omitted, leads to dirty and
hard-to-follow code
 

INSTEAD, ATTACH AS PROPERTY OF WINDOW :
 
 window.myGlobalVar = "foo"; // does the same thing as the example
above, but makes it easy for you and others to see that the variable
is globally scoped.
 

On Jul 9, 12:41 pm, BaBna  wrote:
> As it seems you want your tb1 global, remove the "var" for declaring
> it.
> Also, your alert(tb1) is likely to be executed before tb1 is defined.
> You need to put your alert in the callback function if you want to be
> sure it works.
>
> On Jul 9, 2:47 pm, Vaidotas Zemlys  wrote:
>
> > Hi,
>
> > When trying out jquery, I ran into seemingly very simple problem. I
> > did a search on internet and did not get any satisfactory result. I am
> > suspecting that the mistake is very simple, so anyone more experienced
> > can help me.
>
> > What I am trying to do is load data from server, then present it in
> > the table, and plot it later. Since I am intending to use flot plugin,
> > and it accepts arrays as an argument, I thought that I load the file,
> > save it to some array, and then plot it when time comes (when user
> > presses something, etc.) So my javascript code goes like this:
>
> >  > script>
> >