[jQuery] Re: live() help

2009-09-07 Thread Cam Spiers
Hi I'm not exactly sure what you mean by "loaded into a div" but I assume
that this script is being loaded into the document after the document/window
is already ready.

It is possible you need to remove the $(window).ready event. Maybe the bound
ready functions have been triggered already and are not being triggered
again.

Regards,
Cam

On Tue, Sep 8, 2009 at 10:29 AM, Dave Maharaj :: WidePixels.com <
d...@widepixels.com> wrote:

>  I have this on a page that gets loaded into a div but its not working
> when loaded. I originally had the page load normally in the browser and it
> worked, only since loading it into the div has it stopped. Not sure if it
> has anything to do with it but i want to add
>
> .live() to the function and give it a try but no idea where to add it just
> to see if that does anything.
>
> Or does anyone have any ideas that might help me to get this working again.
>
> $(window).ready(function() {
>  $('.sliderGallery').each(function(){
>   var id_parts = $(this).attr('id').split('_');
>   var id = id_parts[id_parts.length - 1];
>   var container = $('#sliderGallery_' + id) ;
>
>
>   var ul = $('ul', container);
>   var itemsWidth = ul.innerWidth() - container.outerWidth();
>
>$('.slider', container).slider({
>  min: 0,
>  max: itemsWidth,
>  handle: '.handle',
>  stop: function (event, ui) {
>   ul.animate({'left' : ui.value * -1}, 500);
>  },
>  slide: function (event, ui) {
>   ul.css('left', ui.value * -1);
>  }
>});
>  });
> });
>
> Thanks,
>
> Dave
>


[jQuery] Re: killSession() PHP function inside $(window).unload

2009-08-23 Thread Cam Spiers
You can attach an unload event to the window.
In the function called from this event you can run a synchronous (this
is imperative) ajax request to a server-side script which kills the session.

$(window).unload(function(event){

$.ajax(

{

async: false,url: "/some-url-to-script-that-kills-session/",
cache: false

}

);

});

Looks like you are mixing javascript and PHP.. Remember PHP is running on
the server side, and any action you perform in the PHP will be performed
when the request to the server is made.

PHP serves the content to the browser.

Hope this helps.

My 2 cents, why would you want to destroy the session when the page reloads?
Wouldn't this be annoying for users?

Cam

On Mon, Aug 24, 2009 at 4:17 AM, Norbert  wrote:

>
> I'm doing a simple chat script and I have the killSession function
> which kills the current session and deletes the user from the DB. The
> problem is that after the name is set and verified the chat form
> doesn't load, it just kills the session and goes back to the loginForm
> (). Here's the script:
>
>  if(!isset($_SESSION['name'])){
>loginForm(); // set a name for chat
> } else {
> ?>
>// chat form
>
>$(window).unload( function () {
>
>});
>
> Is there a way to trigger killSession() only after I refresh or close
> the page?
>


[jQuery] Re: AJAX and JSON

2009-08-10 Thread Cam Spiers
I also recommend using json2.js for anything more then just a basic
key-value json string.

I ran into troubles with the standard jQuery json approach, when
implementing a complex system that transfers a lot of json to and from the
server.

And as Michael Geary mentions:

"If you want to *generate* JSON in your JavaScript code (e.g. if your server
> expects you to send it JSON data in a POST), JSON.stringify() from json2.js
> is the way to do it."
>

Cam

On Tue, Aug 11, 2009 at 3:13 PM, MorningZ  wrote:

>
> "Speaking of: i recommend AGAINST using getJSON()"
>
> I'd also recommend against use of $.getJSON for a totally different
> reason:
>
> There is no option to "catch" errors.
>
> getJSON: function(url, data, callback) {
> return jQuery.get(url, data, callback, "json");
> },
>
> so if something happens server side or there is a glitch in the Matrix
> that we call the internet, your code would just dead stop, and your
> user would be sitting there waiting and waiting and waiting
>
>
>
> On Aug 10, 9:54 pm, Miket3  wrote:
> > I'll just add my 2 cents from novice to novice.
> > 1. JSON is just a lightweight markup language. Its like HTML, and more
> > like XML but just without the weight. And it is easier to read with
> > the eyeball.
> > JSON uses {} squiggles and : and [] and others to markup the data.
> >
> > JSON {"CATALOG" : "JCPENNY"}
> > XML   JCPENNY
> >
> > http://www.json.org/example.html  has some good comparisons.
> >
> > On Aug 10, 6:26 pm, "Michael Geary"  wrote:
> >
> > > > > From: Joey Derrico
> >
> > > > > I am a novice at AJAX and JSON (Ok, I am a novice at
> > > > > JavaScript.), and
> > > > > I am brand new to jQuery. I wanted to use JSON in a project I am
> > > > > working on and I read various tutorials on using JSON with jQuery
> > > > > however none of them answered some of my questions. The biggest one
> > > > > is, does jQuery support JSON or do I need to use another
> > > > > JSON library to use JSON with jQuery?
> > > > From: Stephan Beal
> >
> > > > JSON is simply a data format. "Supporting" JSON simply means having:
> >
> > > > a) a function which can transform JS objects into a
> > > > JSON-compliant string.
> > > > b) a function which can transform a compliant string into a JS
> object.
> >
> > > > AFAIK, jQuery doesn't have any built-in support for JSON, but
> > > > it doesn't have to - it doesn't operate at a level where JSON
> > > > would be useful (except for possible selector-style traversal
> > > > of a JSON tree).
> >
> > > > The canonical JSON implementation for JavaScript is Doug
> > > > Crockford's json2.js, available here:
> >
> > > >http://www.json.org/
> >
> > > > See JSON.stringify() and JSON.parse().
> >
> > > Actually, jQuery does provide quite a bit of built-in JSON support, and
> for
> > > a large category of apps, it provides all the support you need.
> >
> > > If you want to make GET or POST requests to a server, get JSON data
> back,
> > > and use that data in your JavaScript code, you don't need json2.js.
> jQuery
> > > supports all of that, both for JSON data on your own server or JSONP
> data
> > > coming from other domains.
> >
> > > Just use $.getJSON() or $.ajax() with the 'json' or 'jsonp' dataType as
> > > needed.
> >
> > > If you want to *generate* JSON in your JavaScript code (e.g. if your
> server
> > > expects you to send it JSON data in a POST), JSON.stringify() from
> json2.js
> > > is the way to do it.
> >
> > > If you want a "safer" JSON parser instead of the "eval-ing" JSON parser
> that
> > > jQuery uses, then JSON.parse() from json2.js will give you that. But
> for
> > > most apps you don't need this (and it's less useful than it might
> sound).
> >
> > > Otherwise, you can just use the JSON support in jQuery.
> >
> > > -Mike
>


[jQuery] Re: Custom Attributes - Beginner tip

2009-08-05 Thread Cam Spiers
Don't be too hard on yourself mate. The docs are your friend too :)

On Wed, Aug 5, 2009 at 10:52 PM, Miket3  wrote:

>
> Damn it!  I stand corrected.  Thanks Jules!   And it worked as I
> thought it should have.  Even though this is only my 2nd jQuery
> project I KNOW for a fact(mostly) that I used the proper syntax and
> method of trying to retrieve my custom attrib.  I have a sneaky
> feeling that I was a victim of browser cache.  There have been a few
> times I have setup something that should work, but doesn't, so I
> replace my code with a work-around, and then if I go back to my
> original setup it magically works.  I hate when I try to help people
> with the wrong information.
>
> On Aug 4, 11:21 pm, Jules  wrote:
> > jQuerysupportcustomattributes, may be you can post a sample?
> >
> > Anyway, this works
> >
> > $(document).ready(function(){
> >alert($("[custom='test']").length);
> >
> > });
> >
> > 
> > 
> > 
> > 
> >
> > On Aug 5, 10:04 am, Miket3  wrote:
> >
> > > One issue I ran across while learningjquerywas that I often wanted/
> > > needed a way to telljqueryto get data for the current element from a
> > > related element.jQueryimmediately tends to be friendly when you need
> > > to work with a class of elements via the CLASS attribute, or a
> > > specific element via the ID attribute. However, when there are 2
> > > elements that are related but do not fit within a class, a beginner
> > > such as myself may have a little trouble trying to find the best way
> > > to handle this issue. At this point we begin to research how to get
> > >jQueryto recognize acustomattribute, because common rules says that
> > > the ID attrib is basically out of the question as this needs to be
> > > unique to each element. And the CLASS attrib just doesn't logically
> > > help either because it can refer to too many other elements that don't
> > > fit our rule. And when we find out thatjQuerydoesn't readily
> > > recognizecustomattributesit can get a little intimidating because
> > > one of the solutions is to extendjQuery.  But there are a couple of
> > > other standardattributesthat are recognized but rarely used.  In my
> > > particular case I started using the TITLE attribute for relating my
> > > elements. But then I stumbled upon the correct way, (or at least until
> > > someone corrects me on this post).  There is a REL attribute which can
> > > be used to RELATE the to elements.  So when you feel like you need a
> > >customattribute, you might not need one, the REL is available and the
> > > TITLE could be used as a backup if necessary.
> >
> > > I hope this helps someone.
>


[jQuery] Re: jquery website broken?

2009-03-18 Thread Cam Spiers
How does it have anything to do with "the package" they are using?
Would be nice to see the site at least using valid markup and css.


On Thu, Mar 19, 2009 at 5:22 AM, donb  wrote:

>
> It's always had that problem since the new site was created.  There
> are floats not being cleared someplace in there.  For what it's worth
> it's not a reflection on jQuery, but on the package being used to run
> the site (Wordpress, perhaps?).
>
> On Mar 18, 11:26 am, Karl Swedberg  wrote:
> > very odd. I remember one other person having a problem with the site a
> > while back. I think he was using a Polish version of IE7, but when he
> > switched it or updated it or something, it started rendering just
> > fine. Sorry, my memory is a little fuzzy on that.
> >
> > I wish there were something I could do, but I'm sort of stuck unless I
> > can replicate the problem on my machine.
> >
> > --Karl
> >
> > 
> > Karl Swedbergwww.englishrules.comwww.learningjquery.com
> >
> > On Mar 18, 2009, at 9:36 AM, iain.wa...@googlemail.com wrote:
> >
> >
> >
> > > Hmm that is odd...You can see a screenshot of how its appearing on XP/
> > > IE7 for me athttp://www.kre8webdesign.com/tmp/jquery.gif, though it
> > > initialy renders correctly, as you can see from screenshot the white
> > > background boxes then appear to lose their height :/
> >
> > > On Mar 18, 1:28 pm, Karl Swedberg  wrote:
> > >> Looks fine to me, too. Can you be more specific about what looks
> > >> broken? Or provide a screenshot or something?
> >
> > >> thanks,
> >
> > >> --Karl
> >
> > >> 
> > >> Karl Swedbergwww.englishrules.comwww.learningjquery.com
> >
> > >> On Mar 18, 2009, at 9:21 AM, MorningZ wrote:
> >
> > >>> What do you see as broken?
> >
> > >>> the page looks and operates fine for me in IE7   (Windows Server
> > >>> 2008
> > >>> and IE7)
> >
> > >>> On Mar 18, 9:11 am, "iain.wa...@googlemail.com"
> > >>>  wrote:
> >  Hi,
> >
> >  I really want to start using jquery in some places to replace
> >  mootools, however i find it extremely difficult to persuade clients
> >  to
> >  go with jquery when the jquery website athttp://
> docs.jquery.com/Main_Page
> >  is completely broken in IE7. Is there any reason for this?- Hide
> >  quoted text -
> >
> > >> - Show quoted text -
>


[jQuery] Re: Showing Ajax response when not empty

2009-03-17 Thread Cam Spiers
Also in the options you should add cache: false


On Wed, Mar 18, 2009 at 8:01 AM, James  wrote:

>
> Don't use $.load. Use $.ajax (or $.get or $.post).
>
> $("#userlogin", "#container").everyTime(7500,function() {
>  $.ajax({
>  url: '/ajax/userlogin',
>  type: 'POST',
>  dataType: 'html',
>  success: function(data) {
>   if (data) {
>$(this).animate(...);
>   }
>  }
> });
> });
>
> This assumes that your everyTime function is working. I'm not sure
> what that is.
>
> On Mar 16, 6:39 pm, Brendan  wrote:
> > I'm not sure where to begin asking for help on this one, so I'll just
> > explain what I'm trying to do.
> >
> > What I want to do is show a notification on the page when another user
> > logs in.
> >
> > Say I am User A, and User B logs in, I want to see a notification that
> > User B has logged in.
> >
> > Right now I have a somewhat working version of this...
> >
> > $("#userlogin", "#container").everyTime(7500,function() {
> >
> > $(this).load("/ajax/userlogin");
> >
> > if($(this).text() != '') {
> >
> > $(this).animate({
> > top: "0px"
> > }, 1000).animate({
> > margin: "auto"
> > }, 2500).animate({
> > top: "-50px"
> > }, 1000, function() { $(this).empty(); });
> > }
> >
> > });
> >
> > I am using the plugin that runs a function every specified interval...
> > so right now my logic is that every 7.5 seconds, I run an ajax call to
> > load in content from the ajax url... and if it is not blank, animate
> > the notification.
> >
> > It sounds like it would already work, and it does sometimes... but
> > sometimes i STILL get a blank notification... even though that if
> > check for no content is there.
> >
> > Any ideas on how I could make this more reliable or do it better?
>


[jQuery] Re: Best practice for processing JSON quickly

2009-03-03 Thread Cam Spiers
I'm not sure if it matters in javascript but I would do this:

var length = item.length;
for ( var g = 0; g < length; g++) {

Instead of this:

for (var g=0; g wrote:

>
> Not sure how much it'll speed up, but instead of:
> item.substr(g,1)
> try: item[g]
>
> Then, go through this post:
> http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly
> (
> http://groups.google.com/group/jquery-en/browse_thread/thread/9889ebd5e10c9122
> )
>
> Instead of concatenating strings into one results variable, use array
> items, and then join them at the end.
>
> On Mar 3, 3:11 pm, René  wrote:
> > I have some JSON that needs processing, e.g.:
> >
> >items["1"] =
> > '1010101001010102011010100010101020101020101010101100110100";
> >items["2"] =
> > '101012101010111001011010111001010121011000";
> >... (x 1000)
> >
> > I need to process ~1000 rows so that each 0, 1 or 2 appear as a small
> > coloured dot. (It's a visualization thing).
> > So here's what I have so far, which works:
> >
> > for (i in items) {
> >html += process (items[i]);
> >}
> >
> > function process (item) {
> > var result = '';
> > for (var g=0; g > switch (item.substr(g,1)) {
> > case "0":
> > result += ' class="grey"> ';
> > result;
> > case "1":
> > result += ' class="blue"> ';
> > break;
> > case "2":
> > result += ' class="red"> ';
> > break;
> > }
> > }
> > result += '';
> > return result;
> > }
> >
> > My question is, is there a faster or more efficient way to iterate
> > through each items' "10101001010220211"? I realize this is not
> > strictly jQuery related, but it seems the smartest Javascript people
> > hang out here. :-)
> >
> > Thanks
> >
> > ...Rene
>


[jQuery] [OT] jQuery

2009-02-25 Thread Cam Spiers
Sorry for OT but just wanted to say a big thank you to the jQuery team and
all the wonderful people who contribute in this group.
What a great framework!

Cheers,
Cam

Developer
Doubleclique
www.doubleclique.com


[jQuery] Re: jquery.corners.js peformance issue

2009-02-22 Thread Cam Spiers
Hi I don't know anything about jquery.corners, but maybe your call needs to
go in a jQuery(window).load call.

Cheers,
Cam

On Sun, Feb 22, 2009 at 3:59 PM, Davis  wrote:

>
> appericate for anyone comments/many thanks.


[jQuery] Re: Dealing with Date Comparison

2009-02-04 Thread Cam Spiers
Sorry if this isn't any help but why don't you do it on the server side?

On Thu, Feb 5, 2009 at 11:39 AM, Bob O  wrote:

>
> Can any one point me in the right direction for my issue.
>
> I have a div with a text value pulled in from a database 01/01/2009
>
> Im trying to write a javascript that can take that value and compare
> it against new Date();
>
> $(document).ready(function() {
>  now = new Date();
>  lastActivityDivs = $('td.yui-dt0-col-LastActivity div');
>  lastActivityDivs.each(function() {
>   if ($(this).val() == (now < 14)) {
>   $(this).addClass('.highlight');
> }
>  });
> });
>
> i know this isnt correct, but it gives you an idea of what im trying
> to accomplish..
>
> Any help would be great.
>
> Thank you


[jQuery] Re: Does anybody make Sifr work with uitabs?

2009-02-01 Thread Cam Spiers
I have got around a similar problem in the past by positioning the element
off the screen instead of hiding it. I don't know if this is applicable or
not.

Cheers,
Cam

On Mon, Feb 2, 2009 at 2:16 PM, slake424 wrote:

>
> Hello, I have stumbled upon a problem with ui.tabs and Sifr3.  If I
> attempt to use sifr to replace text within a tab, and that tab is
> hidden, the text never gets converted with Sifr. Sifr works on the
> first tab which is visible but when I open the next tab the text that
> supposed to be replaced is not replaced. If anyone success to make
> SIfr works on the hidden tab as well, please let me know what I can
> do.
>
> Thanks in advance.
>
> Slake424
>


[jQuery] Re: Validation: Which and why...

2009-01-07 Thread Cam Spiers
I like to implement all my validation logic server side and to make it more
userfriendly I like to ajax my forms and send the validation errors back as
json.

I know this might not be the prefered method for some but it means you only
have to write your validation code in one language. (because as Will
mentioned you absolutley must do server side validation)

It also means you can validate things like usernames and email properly, eg
they have to be unique so you can check the database :).

Cheers,
Cam

On Thu, Jan 8, 2009 at 2:08 PM, Nikola  wrote:

>
> Thanks for the info, I was thinking along the same lines but wasn't
> altogether sure.


[jQuery] Re: Event callback question

2009-01-02 Thread Cam Spiers
Interesting I have figured out the reason why your example didn't work(and
now does). It doesn't work when you have elements in the array which don't
need animation/are in the same state initially as the final animation state.

So I now have an active class indicating it's state and the selector I use
is now 'div.mainLiner div.active'

Thanks a lot for your help. This thread is now solved.

Cheers,
Cam

On Sat, Jan 3, 2009 at 1:18 PM, Ricardo Tomasi wrote:

>
> Strange. In my tests the last element's callback was always called
> last. jQuery's animations are time-based, that means both animations
> should end at the same time, with a small offset for the last element
> at most.
>
> Anyway, you already have a solution. I had first rewritten yours
> before trying the other way, with each() you get the element's index
> "for free".
>
> function closeMainPanels(callback){
>var panels = jQuery('div.mainLiner div.panel');
> var last = panels.length-1;
>panels.each(function(index){
> jQuery(this).slideUp(750, function(){
> if (index == last){
>        callback();
>}
>});
>});
> }
>
> cheers,
> - ricardo
>
> On Jan 2, 8:52 pm, "Cam Spiers"  wrote:
> > Thats cool thanks Brian and Ricardo for your time.
> >
> > Ricardo that did look really good but it doesn't work for me.
> >
> > jQuery("div.mainLiner div.panel").not(':last')
> > .slideUp(750, function(){
> > console.log("not last");}).end()
> >
> > .filter(':last')
> > .slideUp(750, function(){
> > console.log("last");
> > //callback}
> >
> > );
> >
> > This in FF in my situation this produces in the firebug console:
> > last
> > not last
> > not last
> >
> > Really unusual.
> > This has the same problem that the callback function is not actually
> being
> > called after the finish of all animations.
> >
> > Cheers,
> > Cam
> >
> > On Fri, Jan 2, 2009 at 7:14 PM, Ricardo Tomasi  >wrote:
> >
> >
> >
> > > You're right, that will run the callback once for each element. This
> > > is a bit hacky but is the shortest way I could think of:
> >
> > > function closeMainPanels(){
> > >jQuery("div.mainLiner div.panel").not(':last').slideUp(750).end()
> > >.filter(':last').slideUp(750, function(){
> > >//callback
> > >})
> > > };
> >
> > > On Jan 2, 1:15 am, "Cam Spiers"  wrote:
> > > > They are all sliding up at the same time, but I was under the
> impression
> > > > that your code would call the callback function once for each
> div.panel
> > > that
> > > > was found. Am I mistaken?
> > > > (would be really awesome if it does only call once)
> >
> > > > And if I'm not, I reiterate that I only want the callback function
> called
> > > > once, and it needs to be called after all of the panels have finished
> > > > animation.
> >
> > > > The reason for this is that I am doing a ajax PUT form submission
> that
> > > > updates a Members account and then returns the updated DOM section.
> Then
> > > I
> > > > replace the old DOM section with the new piece after all of the open
> > > panels
> > > > (which display the content which is about to be replaced) are closed.
> >
> > > > Cheers.
> >
> > > > On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi <
> ricardob...@gmail.com
> > > >wrote:
> >
> > > > > If they are all sliding up at the same time, isn't it simpler to
> use
> >
> > > > > function closeMainPanels(){
> > > > >jQuery("div.mainLiner div.panel").slideUp(750, function(){ /
> > > > > *...callback...*/ });
> > > > > }
> >
> > > > > On Jan 1, 5:53 pm, "Cam Spiers"  wrote:
> > > > > > function closeMainPanels(callback){
> > > > > > var panels = jQuery('div.mainLiner div.panel');
> > > > > > var done = [];
> > > > > > var length = panels.length;
> > > > > > panels.each(function(){
> > > > > > var panel = jQuery(this);
> > > > > > panel.slideUp(750, function(){
> > > > > > if (done.push(panel) == length){
> > > > > > callback();
> > > > > > }
> > > > > > });
> > > > > > });
> >
> > > > > > }
> >
> > > > > > This is what I ended up using thanks brian. :)
> >
> > > > > > Cheers,
> > > > > > Cam
> >
> > > > > > On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers 
> > > wrote:
> > > > > > > Hey,
> >
> > > > > > > function closeMainPanels(){
> > > > > > > jQuery("div.mainLiner div.panel").each(function(){
> > > > > > > jQuery(this).slideUp(750);
> > > > > > > });
> > > > > > > }
> >
> > > > > > > How can I tell when all panels have finished animation?
> >
> > > > > > > As I need to call another function when all have finished.
> >
> > > > > > > Cheers,
> > > > > > > Cam
>


[jQuery] Re: Event callback question

2009-01-02 Thread Cam Spiers
Thats cool thanks Brian and Ricardo for your time.

Ricardo that did look really good but it doesn't work for me.

jQuery("div.mainLiner div.panel").not(':last')
.slideUp(750, function(){
console.log("not last");
}).end()
.filter(':last')
.slideUp(750, function(){
console.log("last");
//callback
}
);

This in FF in my situation this produces in the firebug console:
last
not last
not last

Really unusual.
This has the same problem that the callback function is not actually being
called after the finish of all animations.

Cheers,
Cam

On Fri, Jan 2, 2009 at 7:14 PM, Ricardo Tomasi wrote:

>
> You're right, that will run the callback once for each element. This
> is a bit hacky but is the shortest way I could think of:
>
> function closeMainPanels(){
>jQuery("div.mainLiner div.panel").not(':last').slideUp(750).end()
>.filter(':last').slideUp(750, function(){
>//callback
>})
> };
>
> On Jan 2, 1:15 am, "Cam Spiers"  wrote:
> > They are all sliding up at the same time, but I was under the impression
> > that your code would call the callback function once for each div.panel
> that
> > was found. Am I mistaken?
> > (would be really awesome if it does only call once)
> >
> > And if I'm not, I reiterate that I only want the callback function called
> > once, and it needs to be called after all of the panels have finished
> > animation.
> >
> > The reason for this is that I am doing a ajax PUT form submission that
> > updates a Members account and then returns the updated DOM section. Then
> I
> > replace the old DOM section with the new piece after all of the open
> panels
> > (which display the content which is about to be replaced) are closed.
> >
> > Cheers.
> >
> > On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi  >wrote:
> >
> >
> >
> > > If they are all sliding up at the same time, isn't it simpler to use
> >
> > > function closeMainPanels(){
> > >jQuery("div.mainLiner div.panel").slideUp(750, function(){ /
> > > *...callback...*/ });
> > > }
> >
> > > On Jan 1, 5:53 pm, "Cam Spiers"  wrote:
> > > > function closeMainPanels(callback){
> > > > var panels = jQuery('div.mainLiner div.panel');
> > > > var done = [];
> > > > var length = panels.length;
> > > > panels.each(function(){
> > > > var panel = jQuery(this);
> > > > panel.slideUp(750, function(){
> > > > if (done.push(panel) == length){
> > > > callback();
> > > > }
> > > > });
> > > > });
> >
> > > > }
> >
> > > > This is what I ended up using thanks brian. :)
> >
> > > > Cheers,
> > > > Cam
> >
> > > > On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers 
> wrote:
> > > > > Hey,
> >
> > > > > function closeMainPanels(){
> > > > > jQuery("div.mainLiner div.panel").each(function(){
> > > > > jQuery(this).slideUp(750);
> > > > > });
> > > > > }
> >
> > > > > How can I tell when all panels have finished animation?
> >
> > > > > As I need to call another function when all have finished.
> >
> > > > > Cheers,
> > > > > Cam
>


[jQuery] Re: Event callback question

2009-01-01 Thread Cam Spiers
They are all sliding up at the same time, but I was under the impression
that your code would call the callback function once for each div.panel that
was found. Am I mistaken?
(would be really awesome if it does only call once)

And if I'm not, I reiterate that I only want the callback function called
once, and it needs to be called after all of the panels have finished
animation.

The reason for this is that I am doing a ajax PUT form submission that
updates a Members account and then returns the updated DOM section. Then I
replace the old DOM section with the new piece after all of the open panels
(which display the content which is about to be replaced) are closed.

Cheers.



On Fri, Jan 2, 2009 at 2:43 PM, Ricardo Tomasi wrote:

>
> If they are all sliding up at the same time, isn't it simpler to use
>
> function closeMainPanels(){
>jQuery("div.mainLiner div.panel").slideUp(750, function(){ /
> *...callback...*/ });
> }
>
> On Jan 1, 5:53 pm, "Cam Spiers"  wrote:
> > function closeMainPanels(callback){
> > var panels = jQuery('div.mainLiner div.panel');
> > var done = [];
> > var length = panels.length;
> > panels.each(function(){
> > var panel = jQuery(this);
> > panel.slideUp(750, function(){
> > if (done.push(panel) == length){
> > callback();
> > }
> > });
> >     });
> >
> > }
> >
> > This is what I ended up using thanks brian. :)
> >
> > Cheers,
> > Cam
> >
> > On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers  wrote:
> > > Hey,
> >
> > > function closeMainPanels(){
> > > jQuery("div.mainLiner div.panel").each(function(){
> > > jQuery(this).slideUp(750);
> > > });
> > > }
> >
> > > How can I tell when all panels have finished animation?
> >
> > > As I need to call another function when all have finished.
> >
> > > Cheers,
> > > Cam
>


[jQuery] Re: Event callback question

2009-01-01 Thread Cam Spiers
function closeMainPanels(callback){
var panels = jQuery('div.mainLiner div.panel');
var done = [];
var length = panels.length;
panels.each(function(){
var panel = jQuery(this);
panel.slideUp(750, function(){
if (done.push(panel) == length){
callback();
}
});
});
}

This is what I ended up using thanks brian. :)

Cheers,
Cam

On Thu, Jan 1, 2009 at 5:26 PM, Cam Spiers  wrote:

> Hey,
>
> function closeMainPanels(){
> jQuery("div.mainLiner div.panel").each(function(){
> jQuery(this).slideUp(750);
> });
> }
>
> How can I tell when all panels have finished animation?
>
> As I need to call another function when all have finished.
>
> Cheers,
> Cam
>
>
>
>
>
>
>
>


[jQuery] Re: Event callback question

2008-12-31 Thread Cam Spiers
Thanks for your response.

Yes I have used that before, but I need to know how to add a callback
function which is called after a set of animations are completed.

If I have an array of dom elements which all need the same animation applied
to them,
how can I tell when all the animations are complete?

Thanks,
Cam

On Thu, Jan 1, 2009 at 8:19 PM, brian  wrote:

>
> On Wed, Dec 31, 2008 at 11:26 PM, Cam Spiers  wrote:
> > Hey,
> >
> > function closeMainPanels(){
> > jQuery("div.mainLiner div.panel").each(function(){
> > jQuery(this).slideUp(750);
> > });
> > }
> >
> > How can I tell when all panels have finished animation?
> >
> > As I need to call another function when all have finished.
> >
>
> slideUp accepts a callback function you could use
>
> http://docs.jquery.com/Effects/slideUp
>


[jQuery] Event callback question

2008-12-31 Thread Cam Spiers
Hey,

function closeMainPanels(){
jQuery("div.mainLiner div.panel").each(function(){
jQuery(this).slideUp(750);
});
}

How can I tell when all panels have finished animation?

As I need to call another function when all have finished.

Cheers,
Cam


[jQuery] Re: how to select the content of the current table row?

2008-12-22 Thread Cam Spiers
var rows = jQuery("tbody tr");

rows.each(function(){
var row = jQuery(this);
row.click(function(event){
alert(row.children("td.hidden_url_field_for_track_list").text());
});
});

Sorry I missed a semicolon..

On Tue, Dec 23, 2008 at 12:21 PM, Cam Spiers  wrote:

> var rows = jQuery("tbody tr");
>
> rows.each(function(){
> var row = jQuery(this)
> row.click(function(event){
> alert(row.children("td.hidden_url_field_for_track_list").text());
> });
> });
>
> Haven't tested but you could try something like this maybe.
>
>
> On Tue, Dec 23, 2008 at 11:40 AM, j0llyr0g3r <
> th3.gr31t.j0lly.r0...@googlemail.com> wrote:
>
>>
>> Hey guys,
>>
>> i'm having a hard time with jquery right now.
>>
>> Imagine the following simple table:
>>
>> CODE:
>>
>> 
>>
>>  
>>  
>>  
>>  
>>  
>>
>>
>>
>>  
>>Title
>>
>>  Genre
>>
>>
>>  Speed
>>
>>
>>  Length
>>
>>  
>>
>>
>>  
>>
>>
>>  Cocktail Lounge
>>
>>
>>  Chill
>>
>>
>>  126
>>
>>
>>
>>  03:03
>>
>>
>>  /mp3/stream/MM-MB-0030-COCKTAIL-LOUNGE-126BPM.mp3
>> 
>>
>> As you can see, the last field of the row gets hidden via CSS.
>> Now i have defined an onclick-Handler for every row of the table like
>> this:
>>
>> CODE:
>>
>>function addClickHandler(tableId)   {
>>
>>var tableObj = document.getElementById(tableId);
>>var tBody = tableObj.getElementsByTagName('TBODY');
>>if(tBody){
>>var rows = tBody[0].getElementsByTagName('TR');
>>}else{
>>var rows = tableObj.getElementsByTagName('TR');
>>}
>>for(var no=0;no>rows[no].onclick = clickOnTableRow
>>}
>>}
>>
>> 'clickOnTableRow' looks like this:
>>
>> CODE:
>>
>>function clickOnTableRow()
>>{
>>  alert ("working!")
>>   }
>>
>> Now, clickOnTableRow() is working when i click on a table row (i can
>> see that because of the alert-box), but how can i now select the
>> contents of the last hidden field of this exact row?
>>
>> I tried it like this:
>>
>> CODE:
>>function clickOnTableRow()
>>{
>>var foo =
>> jQuery(this).('hidden_url_field_for_track_list').text();
>>console.info("content: " + foo);
>>}
>>
>> but this gives me:
>>
>> "content: undefined"
>>
>> Then i tried:
>>
>>function clickOnTableRow()
>>{
>>var foo = jQuery('hidden_url_field_for_track_list').text();
>>console.info("content: " + foo);
>>}
>>
>> but this gives me just:
>>
>> "content:"
>>
>> What am i doing wrong here?
>>
>>
>> But no
>
>
>


[jQuery] Re: how to select the content of the current table row?

2008-12-22 Thread Cam Spiers
var rows = jQuery("tbody tr");

rows.each(function(){
var row = jQuery(this)
row.click(function(event){
alert(row.children("td.hidden_url_field_for_track_list").text());
});
});

Haven't tested but you could try something like this maybe.

On Tue, Dec 23, 2008 at 11:40 AM, j0llyr0g3r <
th3.gr31t.j0lly.r0...@googlemail.com> wrote:

>
> Hey guys,
>
> i'm having a hard time with jquery right now.
>
> Imagine the following simple table:
>
> CODE:
>
> 
>
>  
>  
>  
>  
>  
>
>
>
>  
>Title
>
>  Genre
>
>
>  Speed
>
>
>  Length
>
>  
>
>
>  
>
>
>  Cocktail Lounge
>
>
>  Chill
>
>
>  126
>
>
>
>  03:03
>
>
>  /mp3/stream/MM-MB-0030-COCKTAIL-LOUNGE-126BPM.mp3
> 
>
> As you can see, the last field of the row gets hidden via CSS.
> Now i have defined an onclick-Handler for every row of the table like
> this:
>
> CODE:
>
>function addClickHandler(tableId)   {
>
>var tableObj = document.getElementById(tableId);
>var tBody = tableObj.getElementsByTagName('TBODY');
>if(tBody){
>var rows = tBody[0].getElementsByTagName('TR');
>}else{
>var rows = tableObj.getElementsByTagName('TR');
>}
>for(var no=0;norows[no].onclick = clickOnTableRow
>}
>}
>
> 'clickOnTableRow' looks like this:
>
> CODE:
>
>function clickOnTableRow()
>{
>  alert ("working!")
>   }
>
> Now, clickOnTableRow() is working when i click on a table row (i can
> see that because of the alert-box), but how can i now select the
> contents of the last hidden field of this exact row?
>
> I tried it like this:
>
> CODE:
>function clickOnTableRow()
>{
>var foo =
> jQuery(this).('hidden_url_field_for_track_list').text();
>console.info("content: " + foo);
>}
>
> but this gives me:
>
> "content: undefined"
>
> Then i tried:
>
>function clickOnTableRow()
>{
>var foo = jQuery('hidden_url_field_for_track_list').text();
>console.info("content: " + foo);
>}
>
> but this gives me just:
>
> "content:"
>
> What am i doing wrong here?
>
>
> But no


[jQuery] Re: Placing .get method results in a div tag

2008-12-18 Thread Cam Spiers
jQuery("#results").html(data);

or:

jQuery("#results").append(data);


On Fri, Dec 19, 2008 at 10:56 AM, evanbu...@gmail.com
wrote:

>
> Hi
>
> I've been using jQuery all of about 12 hrs now. I want to place the
> results I get back from results.aspx into the div "results" rather
> than alert it out.  Thanks.
>
> 
>
> function addNumbers() {
> var number1 = $('#number1').attr('value');
> var number2 = $('#number2').attr('value');
>$.get("results.aspx", { number1: number1, number2:
> number2 },
>function(data){
>alert("Data Loaded: " + data);
>// want to place data value in results div here
>});
>}
> 
>
>  +  id="number2" value="0" />
>  
>
>  
>


[jQuery] Re: Browser Hangs while hiding 2K+ table rows

2008-12-18 Thread Cam Spiers
If you are trying to hide allrows would it be possible to hide either the
table or the tbody?

On Fri, Dec 19, 2008 at 7:28 AM, RickyBerg  wrote:

>
> I've been converting a legacy web app to use JQuery.  I've now cleaned
> it up so that my HTML validates and I have instrumented the code with
> classes and id's as appropriate.  This app is essentially a table that
> displays the status of jobs for Autosys.
>
> The problem that I'm having is that when I hide the entire list, the
> browser hangs for several minutes.
>
> There are sometimes over 2000 rows.  I have cached the full resultset
> into a variable, though I'm not sure how helpful this is.
>
> In the code below, the initial setting of $allRows doesn't take much
> time at all, but when I hit the hide() line, the browser hangs for
> wy too long.  interestingly, if I comment out the hide() command,
> and then manually issue a comand like $allRows.css("color", "red"); it
> works in a very reasonable amount of time.
>
> $(function() {
>$allRows = $("tbody>tr");
>$allRows.hide();
> }
>
> Also, if I let it run once to completion and all of the rows are
> hidden, then I can show() them and hide() them in reasonable time.
>
> Is it something with my selector?
>
> Thanks, folks.
>
> Eric
>


[jQuery] Re: Is there a way to functionally IGNOR 'Object Expected' FATAL errors with IE6 IE7 ??

2008-12-17 Thread Cam Spiers
>
> I though it was the need to install the JRE java stuff as I'm running
> XPsp2 in virtualbox.


JavaScript doesn't have anything to do with Java apart from the similarities
in naming.

If you send a link to your code people might be able to help out :)

Sorry but I do think you will have to debug to get things working in IE...
It would be great if there was a magic button but sadly I have not yet come
across one :(

If you don't have a live version to show us you can use this free tool.
http://pastebin.com/
To share your code.

Good Luck


On Thu, Dec 18, 2008 at 11:56 AM, yvonney  wrote:

>
> Hi!!! Well after 1000's of newbie hours I've got my page looking
> nice in IE and FF.
> Thing is I get absolutely NO JQuery or Javascript funtioning in IE6 or
> IE7...
>
> I though it was the need to install the JRE java stuff as I'm running
> XPsp2 in virtualbox.
>
> Anyways... I get the Obect Expected message when I try to click on ANY
> JS and/or JQ spots.
>
> and yes... there's a TON of error in the FF console...
> Well,,, what I'd LIKE to do is just IGNOR and be able to RUN the
> scripts live with IE6 an IE7
>
>
> May I ask IF there's a way to simply ignor YET run without going
> through a year of attempting to debug...
> Fact is debugging my attempt could take years.
>
> Kind of a show stopper disappointment which really surprised me after
> getting things looking and working right in Firefox.
>
> thanks for reading!


[jQuery] Re: [OT] Client side web application with jQuery

2008-12-17 Thread Cam Spiers
Oh and I would suggest you try it in Firefox as that is the only browser I
tested in.

On Thu, Dec 18, 2008 at 8:36 AM, Cam Spiers  wrote:

> Hey Leandro,
>
> These links might help..
>
> Here is some stuff I just wrote up:
>
> HTML/JavaScript: http://pastebin.com/m5d3766dd
>
> PHP: http://pastebin.com/m3fb38f94
>
> This link helped me:
> http://www.peej.co.uk/articles/http-auth-with-html-forms.html
>
> I just worked on it for a short time...
> Username: user
> Password: password
>
> Cheers,
> Cam
>
>
>
> On Thu, Dec 18, 2008 at 3:12 AM, Andy Matthews 
> wrote:
>
>>
>> You could use this base64 library to check an encrypted password:
>>
>> http://www.webtoolkit.info/javascript-base64.html
>>
>> Any login done solely with client side code is going to be inherently
>> insecure. If that's part of your requirement, then you'll just have to
>> work
>> around it.
>>
>>
>> andy
>>
>> -Original Message-
>> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>> Behalf Of Leandro Ardissone
>> Sent: Tuesday, December 16, 2008 5:00 PM
>> To: jQuery (English)
>> Subject: [jQuery] [OT] Client side web application with jQuery
>>
>>
>> Hi,
>>
>> I'm need to implement a website (intranet) that runs everything on the
>> client side communicating to the server via RESTful requests. I'm using
>> jQuery but my big issue at the moment is how to manage the login.
>>
>> I'm not sure which is the best method to login the user securely from
>> javascript. We're using REST for the site requests and HTTP Auth for the
>> authentication at the moment, but I don't want to use that ugly browser
>> login.
>>
>> I want to manage everything from the client side using javascript. But
>> since
>> javascript is viewable by the users I think that probably could be
>> dangerous.
>>
>> What are your suggestions? Is there a jQuery plugin for http-Auth? Or
>> maybe
>> I should use other method?
>>
>>
>> Thanks,
>> Leandro
>>
>>
>>
>


[jQuery] Re: [OT] Client side web application with jQuery

2008-12-17 Thread Cam Spiers
Hey Leandro,

These links might help..

Here is some stuff I just wrote up:

HTML/JavaScript: http://pastebin.com/m5d3766dd

PHP: http://pastebin.com/m3fb38f94

This link helped me:
http://www.peej.co.uk/articles/http-auth-with-html-forms.html

I just worked on it for a short time...
Username: user
Password: password

Cheers,
Cam


On Thu, Dec 18, 2008 at 3:12 AM, Andy Matthews wrote:

>
> You could use this base64 library to check an encrypted password:
>
> http://www.webtoolkit.info/javascript-base64.html
>
> Any login done solely with client side code is going to be inherently
> insecure. If that's part of your requirement, then you'll just have to work
> around it.
>
>
> andy
>
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> Behalf Of Leandro Ardissone
> Sent: Tuesday, December 16, 2008 5:00 PM
> To: jQuery (English)
> Subject: [jQuery] [OT] Client side web application with jQuery
>
>
> Hi,
>
> I'm need to implement a website (intranet) that runs everything on the
> client side communicating to the server via RESTful requests. I'm using
> jQuery but my big issue at the moment is how to manage the login.
>
> I'm not sure which is the best method to login the user securely from
> javascript. We're using REST for the site requests and HTTP Auth for the
> authentication at the moment, but I don't want to use that ugly browser
> login.
>
> I want to manage everything from the client side using javascript. But
> since
> javascript is viewable by the users I think that probably could be
> dangerous.
>
> What are your suggestions? Is there a jQuery plugin for http-Auth? Or maybe
> I should use other method?
>
>
> Thanks,
> Leandro
>
>
>


[jQuery] Re: event fires exponentially

2008-12-16 Thread Cam Spiers
I think that ajaxForm already adds a submit handler to the form you are
adding it to...
So i think this is doubling up.

   $('input', $form).change(function(){
   $form.submit();
   });

On Wed, Dec 17, 2008 at 6:33 AM, Jan Limpens  wrote:

>
> And this does work:
>
> $(document).ready(function(){
>$form = $('#filter-form');
> $('input', $form).change(function(){
>$form.ajaxSubmit({
>dataType: 'json',
>success: function(){},
>target: "#layout-child-output"
>});
>});
> })
>
> strange, though
>
> On Tue, Dec 16, 2008 at 3:27 PM, Jan Limpens 
> wrote:
> > Must be some bug in ajaxForm, I guess.
> >
> > if I change
> >   $('input', $form).change(function(){
> >   $form.submit();
> >   });
> >
> > to
> >   $('input', $form).change(function(){
> >   alert('peng');
> >   });
> >
> > it fires once only, otherwise I get the exponential behavior. My guess
> > is, that ajaxForm.submit() somehow touches the inputs and triggers the
> > change event recursively. But that is just my impression...
> >
> > On Tue, Dec 16, 2008 at 3:12 PM, Jan Limpens 
> wrote:
> >> No, unfortunately... but I may be able to put something up...
> >>
> >> On Tue, Dec 16, 2008 at 3:05 PM, Eric Hobo Garside 
> wrote:
> >>>
> >>> Do you have a live environment where this is hosted, or at least the
> >>> code for the page to test it locally? Looks like it should be working
> >>> fine, at face value.
> >>>
> >>> On Dec 16, 11:55 am, "Jan Limpens"  wrote:
>  Hi guys,
> 
>  I have this piece of innocent looking code:
> 
>  
>  $(document).ready(function(){
>  $form = $('#filter-form');
>  $form.ajaxForm({
>  //dataType: 'json',
>  success: function(){
>  alert("peng");
>  },
>  target: "#layout-child-output"
>  });
>  $('input', $form).change(function(){
>  $form.submit();
>  });})
> 
>  
> 
>  If I check one checkbox, I get one submit, for 2 2, however for 3 4,
>  for 4 16, and so on until the server crashes.
> 
>  Any idea what is wrong here?
>  --
>  Jan
> >>
> >>
> >>
> >> --
> >> Jan
> >>
> >
> >
> >
> > --
> > Jan
> >
>
>
>
> --
> Jan
>


[jQuery] Re: Trying to assign onClick to a link

2008-12-16 Thread Cam Spiers
 $('a#link').click(function(event) {
 event.preventDefault();
 $('div#bugDiv').slideToggle('slow');
});

You can do this as well.

On Wed, Dec 17, 2008 at 3:26 AM, Matt  wrote:

>
> Worked perfectly. Thanks Michael and Mike!!
>
> On Dec 16, 6:43 am, Michael Price  wrote:
> > Matt wrote:
> > > Hi everyone,
> >
> > > I'm very new to jQuery and am trying to have a div toggle between
> > > hidden and shown using the slideToggle function. This is my code that
> > > I have in the head of my html:
> >
> > > $(document).ready(function(){
> > >$('a#link').click(
> > >$('div#bugDiv').slideToggle('slow')
> > >);
> >
> > > });
> >
> > > The link that I want to associate the onClick to has an id of "link"
> > > and the div has an id of "bugDiv".
> >
> > > Right now, the way it works, the bugdiv slides to hidden on load, as
> > > though it's just executing the code as opposed to associating it as
> > > the onclick action..
> >
> > > Any help would be appreciated! Thanks in advance,
> > > Matt
> >
> > Hi Matt
> > I think the click handler will need wrapping in a function as well:
> >
> > $('a#link').click(function() {
> > $('div#bugDiv').slideToggle('slow');
> > return false;
> >
> > });
> >
> > I've also added return false as Mike suggested which will stop the
> > link's default action from being followed.
> >
> > Regards,
> > Michael Price
>


[jQuery] Re: jQuery and PHP form problem

2008-12-16 Thread Cam Spiers
Just as a side note..

if(isset($_POST['search_button'])){
   echo $_POST['search_field'];
}

You should use an isset()