[jQuery] Re: upload file

2009-04-16 Thread Joseph Le Brech

try ocupload, or one click uploader.

> Date: Fri, 17 Apr 2009 08:02:32 +0700
> From: donnykur...@gmail.com
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: upload file
> 
> 
> ybs@gmail.com wrote:
> > I seach a simple way to upload file using ajax and jquery
> > 
> 
> http://malsup.com/jquery/form/
> 
> Other alternative is use flash uploader. One that I found interesting:
> http://www.uploadify.com/
> 
> --
> Donny Kurnia
> http://hantulab.blogspot.com
> http://www.plurk.com/user/donnykurnia
> 

_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/

[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread RobG



On Apr 17, 10:08 am, Josh Powell  wrote:
> @all - thanks for all the comments.  Love the heated discussion.
>
> @RobG - can you code up some example code as to how you would solve
> the same problem I presented code for?

OK, here is a dead basic proof of concept.  Of course it is nowhere
near production code, but I think you can see where it's going.  I
would wrap the entire thing in the module pattern, but I've just used
basic globals at this stage.  My intention is to show that efficient
DOM manipulation is possible and that access to related data isn't
hard.

It took me about 45 minutes to write the entire thing (more than half
of that was writing the function to generate the test data set),
tested in Firefox 3 and IE 6 on a 3.4GHz Pentium 4, Windows XP, the
insert runs in less than 500ms.  I'll test it on the G4 iBook for
reference later.


http://www.w3.org/TR/html4/strict.dtd";>

 
  Local data
  
.templateRow {
  display: none;
}
  
  

var dataObj = {};

// Utility functions
// Pad with zeros to 5 chars long
var padZ = (function () {
  var z = '0';
  var len = z.length;
  return function(s) {
s = String(s);
return z.substring(0,len - s.length) + s;
  }
})();

var insertText = (function() {
  var span = document.createElement('span');
  if (typeof span.textContent == 'string') {
return function(el, text) {
  el.textContent = text;
}
  } else if (typeof span.innerText == 'string') {
return function(el, text) {
  el.innerText = text;
}
  } else if (typeof span.innerHTML == 'string') {
return function (el, text) {
  el.innerHTML = text;
}
  }
  span = null;
})();

// Return a random number between 0 and n-1
function getRandN(n) {
  return (Math.random()*n)|0
}

// Generate some data
function genData(n) {
  var key, dataObj = {};
  var types = ['movie', 'book', 'DVD'];
  var tLen = types.length;
  var abouts = ['Adventure', 'Drama', 'Thriller'];
  var aLen = abouts.length;
  for (var i=0; ihttp://www.google.com/?' + i
}
  }
  return dataObj;
}

// Insert data into table
function insertData(id, dataObj) {
  var table = document.getElementById(id);
  var tBody = table.tBodies[0];
  var templateRow = tBody.rows[0];
  var a, cells, cell, newRow;
  var frag = document.createDocumentFragment();

  for (var key in dataObj) {
newRow = templateRow.cloneNode(true);
newRow.className = 'rowClass';
cells = newRow.getElementsByTagName('td');
a = cells[0].firstChild;
insertText(a, dataObj[key].name);
a.href = dataObj[key].href;
a.onclick = dumbListener;
a.id = key;
frag.appendChild(newRow);
  }
  tBody.appendChild(frag);
  tBody.onclick = showData;
}

function showData(evt) {
  var evt = evt || window.event;
  var tgt = evt.target || evt.srcElement;
  var data;
  if (tgt && tgt.tagName && tgt.tagName.toLowerCase() == 'a') {
data = dataObj[tgt.id];

// Have data related to this element, do
// something with it
alert(
'Name: ' + data.name
  + '\nType: ' + data.type
  + '\nAbout: ' + data.about
);
  }
}

function dumbListener(){
  return false;
}

window.onload = function() {
  dataObj = genData(500);
  var s = new Date();
  insertData('t0', dataObj);
  alert('Inserting data took: ' + (new Date() - s) + 'ms');
}
  
 
 
   
 
   Column 1
   Column 2
   Column 3
   Column 4
   Column 5
 
   
  
  
  
  
  
  
 



--
Rob


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Michael Geary

I must be missing something obvious, but it sounds like you're not just
working with some predetermined HTML, but you have the flexibility to tweak
that HTML code, is that right?

Then why can't you generate this as part of your HTML page:


// initialize some variables here


That *is* HTML code, isn't it?

-Mike

> From: kgosser
> 
> I have two values that are only found in a loop in the HTML. 
> They need to be passed to the single function in the document.ready().
> 
> I can't set them in the JavaScript. I have to "find" them 
> somehow in the HTML. Whether I find them as hidden inputs or 
> something, or as tags to the anchor, or as params passed in 
> somehow. I'm not sure what's best.



[jQuery] Re: jQuery script simplification question

2009-04-16 Thread Richard D. Worth
You only need one document.ready, and there's a shorthand:

$(function() {

  $("li.one").click(function() {
$("div.a").toggle("highlight", {}, 1000);
  });
  $("li.two").click(function() {
$("div.b").toggle("highlight", {}, 1000);
  });
  $("li.three").click(function() {
$("div.c").toggle("highlight", {}, 1000);
  });

});

If you're wanting to go even more minimal:

$(function() {

  var hash = { "one": "a", "two": "b", "three": "c" };
  $("li.one,li.two,li.three").click(function() {
$("div." + hash[this.className]).toggle("highlight", {}, 1000);
  })

});

- Richard

On Fri, Apr 17, 2009 at 12:26 AM, Calvin  wrote:

>
>  I'm having trouble simplifying my jQuery script... I tried but I am
> at beginner level with this stuff.
>
> Here is the jQuery script:
>
>  $(document).ready(function() {
>("li.one").click(function() {
>  $("div.a").toggle("highlight", {}, 1000);
>});
>  });
>
>   $(document).ready(function() {
>("li.two").click(function() {
>  $("div.b").toggle("highlight", {}, 1000);
>});
>  });
>
>   $(document).ready(function() {
>("li.three").click(function() {
>  $("div.c").toggle("highlight", {}, 1000);
>});
>  });
>
> Here is the mark-up:
>
>  
>  text
>  text
>  text
>  
>
>  text
>  text
>  text


[jQuery] jQuery script simplification question

2009-04-16 Thread Calvin

  I'm having trouble simplifying my jQuery script... I tried but I am
at beginner level with this stuff.

Here is the jQuery script:

  $(document).ready(function() {
("li.one").click(function() {
  $("div.a").toggle("highlight", {}, 1000);
});
  });

   $(document).ready(function() {
("li.two").click(function() {
  $("div.b").toggle("highlight", {}, 1000);
});
  });

   $(document).ready(function() {
("li.three").click(function() {
  $("div.c").toggle("highlight", {}, 1000);
});
  });

Here is the mark-up:

  
  text
  text
  text
  

  text
  text
  text


[jQuery] Re: $.ajax get with ?var=123 not accepting data type

2009-04-16 Thread Rogue Lord

Ok, I figured out that because the links that are not working are in
the pages that are being pulled up into the main_content div, anyone
know how I can modify the code to run scripts that would modify the
same div?

On Apr 16, 6:32 pm, Rogue Lord  wrote:
> 
>         $(document).ready(function(){
>                 $('#main_content').load('cityhall.php');
>                 $('#loading').hide();
>                 $('a').click(function() {
>                         $("#main_content").slideUp();
>                         var replacement = $(this).attr("title");
>                         var content_show = $(this).attr("id");
>                         $.ajax({
>                                 method: "get", url: replacement, data: 
> content_show,
>                                 beforeSend: 
> function(){$("#loading").show("fast");},
>                                 complete: 
> function(){$("#loading").hide("fast");},
>                                 success: function(html){ //so, if data is 
> retrieved, store it in
> html
>                                         $("#main_content").slideDown("slow"); 
> //animation
>                                         $("#main_content").html(html); //show 
> the html inside .content
> div
>                                 }
>                         });
>                         $.ajax({
>                                 method: "get", url: 
> 'includes/side_mini.inc.php',
>                                 success: 
> function(html){$("#side_details").html(html);}
>                         });
>                         $.ajax({
>                                 method: "get", url: 
> 'includes/side_mini2.inc.php',
>                                 success: 
> function(html){$("#activity").html(html);}
>                         });
>                 });
>         });
> 
>
> In the first AJAX Get call it has a "data: vars" field that I was
> trying to use to pass a get var to the php like ?id=1, any ideas how I
> can do that to bring up a page like stats.php?id=1 ??? Thanks before
> hand!


[jQuery] Re: how can I delete all elements: children and parent

2009-04-16 Thread Raja Koduru

mkmanning,
you are right.
my mistake.
-raja

On Thu, Apr 16, 2009 at 9:38 PM, mkmanning  wrote:
>
> But won't work if the parent element contains other elements. Why not
> just use .remove() on the span? Btw, an ID that is a number (or starts
> with a number) is invalid.
>
> On Apr 16, 6:21 am, Raja Koduru  wrote:
>> $("#57").parent().empty()
>>
>> could work.
>> check here:http://docs.jquery.com/Manipulation
>>
>> On Thu, Apr 16, 2009 at 6:01 PM, dziobacz  wrote:
>>
>> > I have:
>>
>> > 
>>
>> > bla bla bla 
>> >  something1 
>> >  DELETE 
>> > 
>>
>> > 
>>
>> > How can I delete span element with id=57 and also everything inside ?


[jQuery] cluetip plugin - Need beforeSend() and error handling override

2009-04-16 Thread DotnetShadow

Hi there,

Recently I've been using cluetip with asp.net in particular calling
ajax pagemethods. I recently came across this problem:

http://stackoverflow.com/questions/361467/is-there-any-way-to-suppress-the-browsers-login-prompt-on-401-response-when-usin

Basically what is happening is my pagemethod needs to be
autheniticated, as such when an ajax request is made to this method a
401 status is given and NTLM prompt is given. The workaround involves
sending a custom header that will help suppress this error.

The problem is cluetip doesn't recognize beforeSend unless I
physically edit the cluetip script. Also having the ability to
override the error method would be handy so that redirection can be
applied instead of displaying an error in the cluetip

Let me know what your thoughts are on this?

Regards DotnetShadow


[jQuery] Re: clueTip plugin - onClose option in the API?

2009-04-16 Thread Karl Swedberg

Hi there,

The plugin already has an onHide option. I just fixed it so that  
within onHide's anonymous function "this" will be the invoking element.


so, your additional option would be :

  onHide: function() {
$(this).parent().removeClass('selectedCell');
  })

You can grab the updated plugin on GitHub:

http://github.com/kswedberg/jquery-cluetip/tree/master

--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Apr 16, 2009, at 1:51 PM, tatlar wrote:



Hi there,

I am using Karl's clueTip plugin in a table. When the user clicks a
link in the table, the clueTip pops up, and the CSS of the table cell
changes using the addClass method (adds a class called
'selectedCell'). This is all well and groovy, but what I want to do in
addition, is that when the user closes the clueTip window, the CSS of
the selected table cell reverts to its previous class. I was looking
for an onClose in the clueTip API options list and could not find
one.

Does anyone know how I could achieve this desired behavior? What I
have right now is that when the user clicks one cell all the current
table cells are reset (have the class removed) and then a class is
applied ('selectedCell'). When another a link is clicked in the table,
all the current table cells with that class have it removed, and the
newly clicked cell has the class applied:

$("a.jTip").click( function() {
   $('table tbody tr td').removeClass('selectedCell');
   $(this).parent().addClass('selectedCell');
}

clueTip is called thus:

$("a.jTip").cluetip({
   cluetipClass: 'jtip',
   arrows: true,
   hoverIntent: false,
   mouseOutClose: true,
   sticky: true,
   activation: 'click',
   splitTitle: '|',
   closeText: 'X',
   closePosition: 'title',
   tracking: true,
   showTitle: true
}) ;

I want to add another option (in pseudo-code):
   onClose: function(e) {
   e.parent().removeClass('selectedCell')
   }

Is this worth modifying the plugin for? Am I even going about this the
right way? Thanks in advance.




[jQuery] Re: question about dealing with JSON callback

2009-04-16 Thread mkmanning

And if we really want to split hairs, JSON isn't a string. It's text.
A string is a specific JavaScript object type with its own associated
methods, which have no meaning in other languages. JSON is a text
format that is completely language independent (and JSON was
specifically designed as a data-interchange format).

What your JSON becomes depends upon who you treat the response;
conventionally it is eval'd and so at that point it is JavaScript.

It's not unconventional however to still refer to JSON that has been
received in an ajax response and eval'd as... JSON or JSON data, or
your 'data object' etc. It's also conventional (and correct) to refer
to the specific eval'd response that the OP gave (see below) as an
object, because that's what it is :)

{
"product_id":"03",
"product_name":"Sample shoe",
"product_brand":"Shoe Brand",
"product_slug":"slug3",
"product_description":"description3",
"product_active":"1",
"product_type":"shoe",
"product_gender":"youth",
"product_sizes":"14",
"product_style":"style 3",
"product_categories":"3",
"product_shipping":"shipping 3",
"product_cost":"40.0",
"product_retail":"70.0"
}



On Apr 16, 5:14 pm, mkmanning  wrote:
> As I said before: it's a string until it's eval'd, which happens with
> the 'json' response type within jQuery, or as I said you can eval the
> response text yourself. At that point it is JavaScript, and it's an
> object whose members you can access with dot or bracket notation and
> that you can iterate over. The OP was indicating that he needed to
> remove the quotes
> "there are quotes on the object side of the json
> where there should be no quotes"
>
> There is no 'object side', there are just name-value pairs within the
> object. The names are strings, strings should be quoted according to
> the RFC which was written by Doug Crockford. As I indicated, you can
> leave the quotes or remove them, as you choose, but was trying to make
> it clear to the OP that that was not where the problem was occuring
> (and correct bad terminology such as 'object side' in much the same
> way Garrett pointed out there's no such thing as "String Brackets").
>
> On Apr 16, 4:28 pm, "Michael Geary"  wrote:
>
> > Ah, the O in JSON does stand for Object, but what does the *N* stand for?
> > :-)
>
> > Notation.
>
> > JSON is a string format: It's a *notation* in the form of a string. This
> > string can represent an object or other data type, but JSON is not the
> > object itself.
>
> > The example JSON that the OP posted is evidence of this. It's clearly a
> > string, because that's the only thing you can put in a text email.
>
> > Does that make sense?
>
> > I didn't follow this discussion, so I'm probably missing the context of this
> > mini-controversy. I'm just addressing the specific question of whether JSON
> > is an actual object or a string that represents an object.
>
> > -Mike
>
> > > From: mkmanning
>
> > > So you're saying JSON is not an object, it's a string? What
> > > does the O stand for then? The OP gave this example JSON:
>
> > > {
> > >         "product_id":"03",
> > >         "product_name":"Sample shoe",
> > >         "product_brand":"Shoe Brand",
> > >         "product_slug":"slug3",
> > >         "product_description":"description3",
> > >         "product_active":"1",
> > >         "product_type":"shoe",
> > >         "product_gender":"youth",
> > >         "product_sizes":"14",
> > >         "product_style":"style 3",
> > >         "product_categories":"3",
> > >         "product_shipping":"shipping 3",
> > >         "product_cost":"40.0",
> > >         "product_retail":"70.0"
> > > }
>
> > > In an ajax response with the reponse type as 'json' (or text
> > > and eval'd yourself if you like), that's an object. It's
> > > composed of name:value pairs. The names are strings. If you
> > > don't like what the RFC says, take it up with Douglas Crockford.
>
> > > On Apr 16, 2:25 pm, dhtml  wrote:
> > > > On Apr 16, 12:42 am, mkmanning  wrote:
>
> > > > > Just an FYI, but there's no 'object side' of the json in
> > > your example.
> > > > > It just an object, consisting of name-value pairs. While you can
> > > > > leave
>
> > > > No, it is not an object. It is a string.
>
> > > > > quotes off of the names, they are strings which, according to the
> > > > > RFC, should be quoted. Doing so will not cause problems, and will
> > > > > save you from potentially running into a situation where
> > > your name
> > > > > conflicts with one of the excessive number of reserved words.
>
> > > > > On Apr 15, 7:05 pm, sneaks  wrote:
>
> > > > > > the way i see it, there are quotes on the object side
> > > of the json
> > > > > > where there should be no quotes...
>
> > > > That makes about as much sense as something the OP would post.
>
> > > > Garrett


[jQuery] Re: upload file

2009-04-16 Thread Donny Kurnia

ybs@gmail.com wrote:
> I seach a simple way to upload file using ajax and jquery
> 

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

Other alternative is use flash uploader. One that I found interesting:
http://www.uploadify.com/

--
Donny Kurnia
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia



[jQuery] cluetip ajax authentication

2009-04-16 Thread DotnetShadow

Hi there,

I've been using cluetip calling an ajax page. The problem I am finding
is that the ajax page is part of forms authentication so if this
expires and a person hovers over an element to display the cluetip it
will try and request the ajax page but come up with NTLM prompt.

How can I detect that the ajax page tried to redirect to login page
and suppress the NTLM username/password prompt?

Regards DotnetShadow


[jQuery] cluetip ajax authentication

2009-04-16 Thread DotnetShadow

Hi there,

I've been using cluetip calling an ajax page. The problem I am finding
is that the ajax page is part of forms authentication so if this
expires and a person hovers over an element to display the cluetip it
will try and request the ajax page but come up with NTLM prompt.

How can I detect that the ajax page tried to redirect to login page
and suppress the NTLM username/password prompt?

Regards DotnetShadow


[jQuery] $.ajax get with ?var=123 not accepting data type

2009-04-16 Thread Rogue Lord


$(document).ready(function(){
$('#main_content').load('cityhall.php');
$('#loading').hide();
$('a').click(function() {
$("#main_content").slideUp();
var replacement = $(this).attr("title");
var content_show = $(this).attr("id");
$.ajax({
method: "get", url: replacement, data: 
content_show,
beforeSend: 
function(){$("#loading").show("fast");},
complete: 
function(){$("#loading").hide("fast");},
success: function(html){ //so, if data is 
retrieved, store it in
html
$("#main_content").slideDown("slow"); 
//animation
$("#main_content").html(html); //show 
the html inside .content
div
}
});
$.ajax({
method: "get", url: 
'includes/side_mini.inc.php',
success: 
function(html){$("#side_details").html(html);}
});
$.ajax({
method: "get", url: 
'includes/side_mini2.inc.php',
success: 
function(html){$("#activity").html(html);}
});
});
});


In the first AJAX Get call it has a "data: vars" field that I was
trying to use to pass a get var to the php like ?id=1, any ideas how I
can do that to bring up a page like stats.php?id=1 ??? Thanks before
hand!


[jQuery] Re: question about dealing with JSON callback

2009-04-16 Thread mkmanning

As I said before: it's a string until it's eval'd, which happens with
the 'json' response type within jQuery, or as I said you can eval the
response text yourself. At that point it is JavaScript, and it's an
object whose members you can access with dot or bracket notation and
that you can iterate over. The OP was indicating that he needed to
remove the quotes
"there are quotes on the object side of the json
where there should be no quotes"

There is no 'object side', there are just name-value pairs within the
object. The names are strings, strings should be quoted according to
the RFC which was written by Doug Crockford. As I indicated, you can
leave the quotes or remove them, as you choose, but was trying to make
it clear to the OP that that was not where the problem was occuring
(and correct bad terminology such as 'object side' in much the same
way Garrett pointed out there's no such thing as "String Brackets").


On Apr 16, 4:28 pm, "Michael Geary"  wrote:
> Ah, the O in JSON does stand for Object, but what does the *N* stand for?
> :-)
>
> Notation.
>
> JSON is a string format: It's a *notation* in the form of a string. This
> string can represent an object or other data type, but JSON is not the
> object itself.
>
> The example JSON that the OP posted is evidence of this. It's clearly a
> string, because that's the only thing you can put in a text email.
>
> Does that make sense?
>
> I didn't follow this discussion, so I'm probably missing the context of this
> mini-controversy. I'm just addressing the specific question of whether JSON
> is an actual object or a string that represents an object.
>
> -Mike
>
> > From: mkmanning
>
> > So you're saying JSON is not an object, it's a string? What
> > does the O stand for then? The OP gave this example JSON:
>
> > {
> >         "product_id":"03",
> >         "product_name":"Sample shoe",
> >         "product_brand":"Shoe Brand",
> >         "product_slug":"slug3",
> >         "product_description":"description3",
> >         "product_active":"1",
> >         "product_type":"shoe",
> >         "product_gender":"youth",
> >         "product_sizes":"14",
> >         "product_style":"style 3",
> >         "product_categories":"3",
> >         "product_shipping":"shipping 3",
> >         "product_cost":"40.0",
> >         "product_retail":"70.0"
> > }
>
> > In an ajax response with the reponse type as 'json' (or text
> > and eval'd yourself if you like), that's an object. It's
> > composed of name:value pairs. The names are strings. If you
> > don't like what the RFC says, take it up with Douglas Crockford.
>
> > On Apr 16, 2:25 pm, dhtml  wrote:
> > > On Apr 16, 12:42 am, mkmanning  wrote:
>
> > > > Just an FYI, but there's no 'object side' of the json in
> > your example.
> > > > It just an object, consisting of name-value pairs. While you can
> > > > leave
>
> > > No, it is not an object. It is a string.
>
> > > > quotes off of the names, they are strings which, according to the
> > > > RFC, should be quoted. Doing so will not cause problems, and will
> > > > save you from potentially running into a situation where
> > your name
> > > > conflicts with one of the excessive number of reserved words.
>
> > > > On Apr 15, 7:05 pm, sneaks  wrote:
>
> > > > > the way i see it, there are quotes on the object side
> > of the json
> > > > > where there should be no quotes...
>
> > > That makes about as much sense as something the OP would post.
>
> > > Garrett


[jQuery] help with jqgrid

2009-04-16 Thread led

b.jgrid is undefined .

i'm having this error when everything seems to be in place . I'm just
starting to try this plugin .


http://realferias.com/jqgrid_demo.htm

thanks


[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Josh Powell

@all - thanks for all the comments.  Love the heated discussion.

@RobG - can you code up some example code as to how you would solve
the same problem I presented code for?

And while it is off topic...can you provide the code you used to run
the benchmarking?  I'm not challenging your results, just want to see
and fiddle with them.  For example, instead of just adding 10k span
nodes, make it 400 table rows with 5 tds and 5 links.  Have the table
rows and tds all have a class, the links a class and an href and text
and compare that against a string with the same.  I bet the creation,
attribute setting, and insertion will take a lot longer.

As for adding 10,000 elements to a page... I am adding up to 500 rows
to a table with 6 tds in each row and a link in 5 of those tds and
text in the other... so that is 500 * 6 * 6, or up to 18,000 nodes.

@Kean - Yes, join is faster... usually.  If speed is of the utmost
importance, then I test using it because I have had it end up being
slower.  Otherwise, I use += because it's more legible.  Even with the
18,000 node case I mentioned above, += finishes up in 486ms in FF
3.0.8 which more then meets our requirements.  I haven't even
benchmarked it with Chrome, but I would guess significantly less.

There are a lot of other things that can be done to speed up insertion
first that make a much larger impact.  See my aforementioned article,
it's a great discussion, I've just been involved in it several
times :).

Thanks all,
Josh

On Apr 16, 12:06 pm, Kean  wrote:
> @Josh Powell
> - string concatenation is plenty fast 99% of the time and a lot more
> readable.
> Yes string concatenation is more readable and 99% faster for normal
> usage. But looping and concatenate a huge chunk in this particular
> case is slower. Reason: every + between 2 strings returns a new string
> before concatenating with other strings. Array.prototype.join does not
> have that problem. You just need more than 6 string concatenation
> (subject to string length and debate) and it will be a good choice for
> Array.prototype.join to take over.
>
> - W3C DOM Node creation is much slower then inserting via innerHTML,
> especially as you add more nodes.  It doesn't matter how fast the
> nodes are created, it will always be slower to create, adjust, and
> insert 10,000 nodes then one string.
> That's old school thinking. Please refer to my original post, I am
> talking about Chrome's v8 engine and browser detection. You will be
> pleasantly surprised. See RobG's comment too.
>
> @RobG
> Thanks for benchmarking.


[jQuery] on_mouse_over scrolling

2009-04-16 Thread macsig

Hi there,
I'm trying to implement a simple scrolling system: basically I have a
div with a specific height and auto overflow and I want to let the div
content scrolling down when the mouse is over an icon. It has to scrol
until the end of the content or until the muose is moved.

But I cannot make it working so far.

Any idea or even better a sample to solve my issue?


Thanks fpr any help, I appreciate it.


Sig


[jQuery] upload file

2009-04-16 Thread ybs....@gmail.com

I seach a simple way to upload file using ajax and jquery


[jQuery] Re: $('body') problem in FireFox

2009-04-16 Thread RavanH

Some additional info:

It seems to be some kind of conflict with about EVERY other little
piece of javascript on the same page... a small date script, google
analytics script, skype check script, google ads, and many others.
After disabling about every other script, the highlights worked in
FF.



Strange how this apparently is no issue at all when any div ID or even
class is used...

Anybody any thoughts about this ?


[jQuery] Re: tabs collapsed by default on open

2009-04-16 Thread Klaus Hartl

On 16 Apr., 20:38, "robintrain...@yahoo.com" 
wrote:
> Hello everyone. Is there a way to have tabs created in jQuery that are
> collapsed when the page loads? I use this:
>
> $(document).ready(function(){
> $("#tabs").tabs({ collapsible: true
>
> });
> });
>
> to allow the user to click on the tab to collapse it once the page
> loads. But how do I get the tab content to be hidden to begin with?

Use:

$(document).ready(function(){
$("#tabs").tabs({
collapsible: true,
selected: -1
});
});

You don't necessarily have to use collapsible in this case by the way.

--Klaus


[jQuery] Re: question about dealing with JSON callback

2009-04-16 Thread Michael Geary

Ah, the O in JSON does stand for Object, but what does the *N* stand for?
:-)

Notation.

JSON is a string format: It's a *notation* in the form of a string. This
string can represent an object or other data type, but JSON is not the
object itself.

The example JSON that the OP posted is evidence of this. It's clearly a
string, because that's the only thing you can put in a text email.

Does that make sense?

I didn't follow this discussion, so I'm probably missing the context of this
mini-controversy. I'm just addressing the specific question of whether JSON
is an actual object or a string that represents an object.

-Mike

> From: mkmanning
> 
> So you're saying JSON is not an object, it's a string? What 
> does the O stand for then? The OP gave this example JSON:
> 
> {
> "product_id":"03",
> "product_name":"Sample shoe",
> "product_brand":"Shoe Brand",
> "product_slug":"slug3",
> "product_description":"description3",
> "product_active":"1",
> "product_type":"shoe",
> "product_gender":"youth",
> "product_sizes":"14",
> "product_style":"style 3",
> "product_categories":"3",
> "product_shipping":"shipping 3",
> "product_cost":"40.0",
> "product_retail":"70.0"
> }
> 
> In an ajax response with the reponse type as 'json' (or text 
> and eval'd yourself if you like), that's an object. It's 
> composed of name:value pairs. The names are strings. If you 
> don't like what the RFC says, take it up with Douglas Crockford.
> 
> On Apr 16, 2:25 pm, dhtml  wrote:
> > On Apr 16, 12:42 am, mkmanning  wrote:
> >
> > > Just an FYI, but there's no 'object side' of the json in 
> your example.
> > > It just an object, consisting of name-value pairs. While you can 
> > > leave
> >
> > No, it is not an object. It is a string.
> >
> > > quotes off of the names, they are strings which, according to the 
> > > RFC, should be quoted. Doing so will not cause problems, and will 
> > > save you from potentially running into a situation where 
> your name 
> > > conflicts with one of the excessive number of reserved words.
> >
> > > On Apr 15, 7:05 pm, sneaks  wrote:
> >
> > > > the way i see it, there are quotes on the object side 
> of the json 
> > > > where there should be no quotes...
> >
> > That makes about as much sense as something the OP would post.
> >
> > Garrett
> 



[jQuery] can jquery capture these events all in one: user closes browser window/tab, or leaves my domain?

2009-04-16 Thread Govinda

Hi all,

I am brand new here.  Except for quick installs of pre-written scripts
over the years, I have very little experience of javascript (do we use
the acronym "js" here?)  I have written in visual basic (I was last
semi-fluent with the 1998 version), and in WebDNA for 10 years (server-
side web scripting language, like PHP, only much less known).

I am writing to ask your opinions about accomplishing a solution to
our need.  I am not sure if we can do this with jQuery or js?

Here is what I need your opinion about how to solve:
  We have a series of forms for the user to submit.  We gather various
data from the user at each form.  We save his input to disk at every
form submission but also eventually want to do some final processing
on his input (do some math, over and above just saving his input).  We
only want to process his data once we have accumulated as much data
from his as possible.. i.e. as much as he has patience to input for
us.  *One special thing is that we can only do this final processing
one time.*  Ideally we want to wait until he reaches formN to do this
final processing of his data.  But if we knew he was only going to
stick around to see form3 and then leave..  then we would simply do
the final processing after he submitted form2.  The problem is that we
never know when the user will get tired and leave.  We would do the
final processing earlier before losing him, but we can only process
once and we don't want to miss the chance to gather yet more data from
him before we process.  If he leaves our site at form2 (or form3, or
form4, for example) then we want to process whatever data we have
gathered from him in total...  meaning *as if he had submitted the
form* he is now looking at after having checked the checkbox which
says "this is my last form!".  We want to process as though he
submitted one last form after alerting us that it was going to be his
last submission - even though he is actually now leaving our site by
closing the browser window, or closing the browser tab, or entering a
new URL to go to..  or using a browser bookmark ..
   I assume there is a way to capture the event that fires when
someone closes the browser window, closes the tab, (or also even if he
just leaves our domain within the current window/tab?)..?
   Can I capture all these possible events (and others that you can
think of that I neglect to mention here) into one umbrella event that
fires and effectively submits the current form one last time - thus
signaling to our server to go ahead with the final processing?

If  jQuery does not have this capability, then what about javascript?
Please advise!

Thanks for your time reading this.
-Govinda


[jQuery] $('body') problem in FireFox

2009-04-16 Thread RavanH

Hi,

I am trying to make a search-term highlight script extension work on
the body element of a page. However, the following code causes a VERY
weird problem in FF2 and FF3. The complete body seems to be removed
after the script runs...

[code]
  var hlst_query  = new Array
("array","of","dynamically","inserted","terms");
  jQuery.fn.extend({
highlight: function(search, insensitive, span_class){
  var regex = new RegExp('(<[^>]*>)|(\\b'+ search.replace(/([-.*+?^
${}()|[\]\/\\])/g,'\\$1') +')', insensitive ? 'ig' : 'g');
  return this.html(this.html().replace(regex, function(a, b, c){
return (a.charAt(0) == '<') ? a : '' + c + '';
  }));
}
  });
  jQuery(document).ready(function($){
if(typeof(hlst_query) != 'undefined'){
  for (i in hlst_query){

$('body').highlight(hlst_query[i], 1, 'hilite term-' + i);
  }
}
  });
[/code]

In IE it all works fine, in Opera the spans are added but after that
the test page does not take any user input anymore...

If I redefine $('body') to be something like $('#content') referring
to a div with ID content, it works in all browsers but ofcource ONLY
inside that div...

Is there a way to make it work for all browsers for the COMPLETE body?
I cannot assume the body has an ID because this script is supposed to
run on different templates...

I tried a lot already but wihtout any results. Please help :)


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Joseph Le Brech

you can also make custom attributes, they don't have to be called "rel" so you 
can have as many attributes as you want.

> Date: Thu, 16 Apr 2009 15:15:44 -0700
> Subject: [jQuery] Re: passing more than 1 param via click()?
> From: kgos...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> That's a good point, Josh. I thought of that earlier, but I wanted to
> make sure this was the best way. For only passing two params, that's
> not that bad of an idea, but I was checking to see if there was a best
> practice here, like hopefully passing the params through somehow.
> 
> On Apr 16, 5:04 pm, "Josh Nathanson"  wrote:
> > You could do something like:
> >
> >  // use a delimiter that makes sense for your values
> >
> > Then split the rel:
> >
> > var arr = this.rel.split('_'), val1 = arr[0], val2 = arr[1];
> >
> > removeDept( val1, val2 );
> >
> > -- Josh
> >
> > -Original Message-
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> >
> > Behalf Of kgosser
> > Sent: Thursday, April 16, 2009 2:47 PM
> > To: jQuery (English)
> > Subject: [jQuery] passing more than 1 param via click()?
> >
> > Hey all,
> >
> > Not really sure how to ask this, so I'm sorry if my title is mis-
> > leading. It is also why I wasn't able to find much searching, so I'm
> > sorry if it's answered already.
> >
> > Basically, the code I inherited was this:
> >
> >  >  href="#drop"
> >  class="edit-link"
> >  onclick="
> >   removeDept('','');
> >   return false;"
> > >Remove Department
> >
> > And that is in an iteration, so the two values passed to the
> > "removeDept" function are always dynamic.
> >
> > I'm trying to handle this in the document.ready(). Normally, I throw
> > the would-be dynamic param passed as a rel tag on an anchor, and
> > that's how I retrieve things when I clean up code like this.
> >
> > However, I'm scratching my head for the *best* way to handle this with
> > the two params now... How do you guys recommend I handle something
> > like that?
> >
> > $(document).ready(function() {
> > $(".edit-link").click(function(){
> >removeDept($(this).attr("rel"),$(this).attr("rel"));
> >return false;
> > });
> > });
> >
> > Obviously I can't have two rel attributes :)
> >
> > Thanks in advance.

_
Share your photos with Windows Live Photos – Free.
http://clk.atdmt.com/UKM/go/134665338/direct/01/

[jQuery] Re: Autocomplete plugin for multiple form fields from a JSON source [autocomplete]

2009-04-16 Thread tatlar

Hi Tom,

Thanks for the ideas. Unfortunately there is a fundamental issue with
my JSON file that I returning and how the autocomplete plugin handles
input.

The JSON file is an object. Jorn's autocomplete plugin only handles
arrays (see here:http://docs.jquery.com/Plugins/Autocomplete). Notice
this sentence in particular:

"For local autocomplete, just pass the data as an array to the
autocomplete plugin."

Passing autocomplete a complex object (such as my JSON file) causes
the browser to hang with multiple queries, due to how autocomplete
automagically parses the information it is given to a URL string, and
it expects an array. I checked a couple of times, and the console log
just spins wildly! :)

It is not the fault of the plugin - it is just me putting the wrong
data type into it.

So, I got around this by creating another JSON file that is just an
array of station names. Autocomplete now parses this just fine, and my
first field is completed. The next part was more tricky - how to
populate the second input field based on the number of report types (I
actually ended up using a  element with the  list
populated with the reports available. My solution is pretty inelegant,
but uses a nice option in Jorns plugin, the result() option (http://
docs.jquery.com/Plugins/Autocomplete/result#handler). Using this, I
can get the match from the first autocomplete call, and write a
callback function that then goes via AJAX to my original complex JSON
object to just get the matching stations object. It is a little long
winded (I iterate over every station in the original JSON object) and
I am sure John Resig would write it much much more nicely, but it
works in about 20ms!

Here is the code:

$(function(){
$.ajax({
type: "GET",
url: "/path/to/simple_array_of_station_names.json",
dataType: "json",
global: false,
success: function(data) {
$.each(data, function() {
$("#stacode").autocomplete(this).result( function
( event, data, mysta ) {
$("#dynamicReport").html( "" ) ;
// Check I am getting the correct station as
selected by autocomplete plugin
// console.log( mysta ) ;
// Use that in the larger JSON object that has all
the report types and times
$.ajax({
type: "GET",
url: "/path/to/reports.json",
dataType: "json",
global: false,
success: function( reports ) {
/*
   NOTE:
   Not sure why $.each(reports.stations.mysta,
function( repSta,repStaObj ) {} ) ;
   does not work - any ideas anyone? It is a
valid way to get the matching station
   in the JSON structure, right? Oh well, lets
just iterate over the whole thing with $.each()
*/
$.each(reports.stations, function
( repSta,repStaObj ) {
// The matching station
if( repSta === mysta ) {
// Quick and dirty DOM markup,
purists look away
var selection =
'   Report ' ;
$.each(repStaObj, function
( repStaRepsTypes, repStaRepsTimes ) {
console.log( "Type is:
"+repStaRepsTypes+" Time is: "+repStaRepsTimes );
selection +=
""+repStaRepsTypes+"" ;
});
selection += '   ' ;
// Update the  element with
the select box
$("#dynamicReport").html
( selection ) ;
}
});
},
error: function() {
alert( "Could not load the available
report list" ) ;
}
});
});
});
},
error: function() {
alert( "Could not load station list for form
autocomplete" ) ;
}
});
});

The inline HTML looks like:



Shortcut to view a stations reports:
Stacode 






So that is my solution. Not pretty. But it works. If anyone would like
to pipe in and tell me where I could improve it, I am all ears!!!

Thanks for the ideas and feedback.

On Apr 15, 5:40 pm, Tom Worster  wrote:
> i have an ajax backend onto a mysql table with about 25 million rows,
> including three searchable indexed text columns. i want a form with three
> text input fields, each with autocomplete.
>
> 1) if all fields are blank when the user starts to type into one of them
> then normal autocomplete happens

[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread kgosser

That's a good point, Josh. I thought of that earlier, but I wanted to
make sure this was the best way. For only passing two params, that's
not that bad of an idea, but I was checking to see if there was a best
practice here, like hopefully passing the params through somehow.

On Apr 16, 5:04 pm, "Josh Nathanson"  wrote:
> You could do something like:
>
>  // use a delimiter that makes sense for your values
>
> Then split the rel:
>
> var arr = this.rel.split('_'), val1 = arr[0], val2 = arr[1];
>
> removeDept( val1, val2 );
>
> -- Josh
>
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of kgosser
> Sent: Thursday, April 16, 2009 2:47 PM
> To: jQuery (English)
> Subject: [jQuery] passing more than 1 param via click()?
>
> Hey all,
>
> Not really sure how to ask this, so I'm sorry if my title is mis-
> leading. It is also why I wasn't able to find much searching, so I'm
> sorry if it's answered already.
>
> Basically, the code I inherited was this:
>
>       href="#drop"
>      class="edit-link"
>      onclick="
>           removeDept('','');
>           return false;"
> >Remove Department
>
> And that is in an iteration, so the two values passed to the
> "removeDept" function are always dynamic.
>
> I'm trying to handle this in the document.ready(). Normally, I throw
> the would-be dynamic param passed as a rel tag on an anchor, and
> that's how I retrieve things when I clean up code like this.
>
> However, I'm scratching my head for the *best* way to handle this with
> the two params now... How do you guys recommend I handle something
> like that?
>
> $(document).ready(function() {
>         $(".edit-link").click(function(){
>                removeDept($(this).attr("rel"),$(this).attr("rel"));
>                return false;
>         });
> });
>
> Obviously I can't have two rel attributes :)
>
> Thanks in advance.


[jQuery] Re: how to streamline my code with Event Delegation?

2009-04-16 Thread dhtml



On Apr 16, 12:28 pm, redsun  wrote:
> i'm sure the jQuery i'm using below is very ineffiecient. the only

I would not doubt that it is inefficient (you are using jQuery).

> syntax that changes are the numbers in the names of my IDs and my
> variables - and even they're matching. everything else is constant.
> i'm told that "event delegation" is the answer, but cant rewrite the
> code appropriately (i tried, but just made a mess of things -
> rookie).
>

Instead, use a simple function for a document event handler
callback:-

document.onclick = documentClicked;

(it is better to us an adapter that would not replace
document.onclick, but for now, that would work for an example of how
to do it.)

In any case, check the target of that callback to see if it has an id
matching a pattern link\d\d.

To pass those \d\d to myPage.asp, use a capturing group. For example:-

/link(\d\d)/

That should appear in documentClicked.

http://www.w3.org/
TR/html4/strict.dtd">







function documentClicked(ev) {
  var target, targetIdExp = /link(\d\d)/;
  if(typeof ev == "undefined") {
ev = window.event;
  }
  target = ev.target;
  if( typeof target == "undefined") {
target = ev.srcElement;
  }

  // check matching criteria.
  if(targetIdExp.test(target.id)) {
getMyPage(RegExp.$1);
  }
}

function getMyPage(id) {
  alert("myPage.asp?id=" + id);
}

document.onclick = documentClicked;





link 12

link 99





[...]

Garrett


[jQuery] Using namespaced event bindings for multiple $.ajax() calls.

2009-04-16 Thread tatlar

Hi there,

I have an application with multiple $.ajax() calls:

(1) When the page loads, an $.ajax() call grabs and parses a JSON
object.
(2) When a link is clicked, an $.ajax() call sends a query to a PHP
page, which returns a JSON object, which is then parsed and displayed.

I have been having problems because both these events have little
spinning icons in different parts of the page to show that an AJAX
query is taking place. I am doing this using the bind() function to a
ajaxSend() namespaced event. I have the (#2) working, by doing the
following:

$("a").bind( 'click.getReport', function() {
$.ajax({
type: "GET",
url: "my.php",
dataType: "json",
global: true,
data: { var1:a, var2:b, var3:c },
   success: function() {},
   error: function() {}
});
}

and

$("#report").bind("ajaxSend.getReport",function(){
$(this).html('Selected reportLOADING...');
});

where #report is the DIV that shows the status on the page.

However, I have not solved the issue of applying a namespaced event
handler to a low-level $.ajax() call that occurs when the page loads
(#1). I have searched online for this, but to no avail - everything
seems to relate to if you are writing you own plugin or just binding
to a click event. I need to somehow bind the $.ajax call to a
namespaced event. The $.ajax() options list does not seem to have an
entry for namespacing, so where do I add it?

Here is the code I currently have:

$(document).ready(function(){
$.ajax({
type: "GET",
url: "/cachexml/json/stalist.json",
dataType: "json",
global: false,
success: function() {},
error: function() {}
});
});

and

$("#dynamicReport").bind("ajaxSend.getList",function(){
$(this).html('');
});

You can see I have the getList class in the binding - but where in the
jQuery $.ajax() code do I reference this? Notice also that I have
global set to true in the 'getReport' namespaced event and set to
false in the 'getList' namespaced event. If I set 'getReport' to
global: false, it no longer works. Clearly I am not doing something
right!

Thanks for any help - I have given up searching online and am getting
desperate!


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread kgosser

I think you've misunderstood my question.

I have two values that are only found in a loop in the HTML. They need
to be passed to the single function in the document.ready().

I can't set them in the JavaScript. I have to "find" them somehow in
the HTML. Whether I find them as hidden inputs or something, or as
tags to the anchor, or as params passed in somehow. I'm not sure
what's best.

Basically, there could be 10 "edit-link" classes, but when a specific
"edit-link" anchor is clicked, I need to perform an Ajax function that
needs two params passed into it that are unique to that "edit-link".

On Apr 16, 4:53 pm, Joseph Le Brech  wrote:
> i think itll be covered in this.
>
> http://stackoverflow.com/questions/224820/how-do-you-pass-arguments-t...
>
>
>
> > Date: Thu, 16 Apr 2009 14:46:41 -0700
> > Subject: [jQuery] passing more than 1 param via click()?
> > From: kgos...@gmail.com
> > To: jquery-en@googlegroups.com
>
> > Hey all,
>
> > Not really sure how to ask this, so I'm sorry if my title is mis-
> > leading. It is also why I wasn't able to find much searching, so I'm
> > sorry if it's answered already.
>
> > Basically, the code I inherited was this:
>
> >  >      href="#drop"
> >      class="edit-link"
> >      onclick="
> >           removeDept('','');
> >           return false;"
> > >Remove Department
>
> > And that is in an iteration, so the two values passed to the
> > "removeDept" function are always dynamic.
>
> > I'm trying to handle this in the document.ready(). Normally, I throw
> > the would-be dynamic param passed as a rel tag on an anchor, and
> > that's how I retrieve things when I clean up code like this.
>
> > However, I'm scratching my head for the *best* way to handle this with
> > the two params now... How do you guys recommend I handle something
> > like that?
>
> > $(document).ready(function() {
> >    $(".edit-link").click(function(){
> >                removeDept($(this).attr("rel"),$(this).attr("rel"));
> >                return false;
> >    });
> > });
>
> > Obviously I can't have two rel attributes :)
>
> > Thanks in advance.
>
> _
> View your Twitter and Flickr updates from one place – Learn 
> more!http://clk.atdmt.com/UKM/go/137984870/direct/01/


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Josh Nathanson

You could do something like:

 // use a delimiter that makes sense for your values

Then split the rel:

var arr = this.rel.split('_'), val1 = arr[0], val2 = arr[1];

removeDept( val1, val2 );

-- Josh

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of kgosser
Sent: Thursday, April 16, 2009 2:47 PM
To: jQuery (English)
Subject: [jQuery] passing more than 1 param via click()?


Hey all,

Not really sure how to ask this, so I'm sorry if my title is mis-
leading. It is also why I wasn't able to find much searching, so I'm
sorry if it's answered already.

Basically, the code I inherited was this:

','');
  return false;"
>Remove Department

And that is in an iteration, so the two values passed to the
"removeDept" function are always dynamic.

I'm trying to handle this in the document.ready(). Normally, I throw
the would-be dynamic param passed as a rel tag on an anchor, and
that's how I retrieve things when I clean up code like this.

However, I'm scratching my head for the *best* way to handle this with
the two params now... How do you guys recommend I handle something
like that?

$(document).ready(function() {
$(".edit-link").click(function(){
   removeDept($(this).attr("rel"),$(this).attr("rel"));
   return false;
});
});



Obviously I can't have two rel attributes :)


Thanks in advance.



[jQuery] Re: Custom Callback not using jQuery object

2009-04-16 Thread Nic Hubbard

Eric,

I now have the need to take the callback out of the scope of the
plugin, and put that into a function that is being called within the
plugin, what would be the best way to do this?

So, if I had:

my_function(defaults.onComplete.apply(obj, []));

For some reason that does not seem like it would work.  Should I just
pass obj?

On Feb 25, 2:40 pm, Eric Garside  wrote:
> Sure. Basically apply allows you to declare the scope of the function
> you're calling, instead of letting that scope resolve normally. With
> any function, it will take on the scope of whatever encloses it. So if
> you declare a function without it being enclosed, "this" will resolve
> to "window" in almost all cases.
>
> function myFunc(){ alert(this); }
> myFunc(); // [object Window]
>
> If your function is enclosed in an object, say:
>
> var obj = { name: 'myObject', myFunc: function(){ alert
> (this.name); } };
> obj.myFunc(); // myObject
>
> then "this" will take on the scope of the object which encloses it.
>
> Using apply, you can manually declare the scope the function will
> have.
>
> var obj1 = { name: 'obj1', myFunc: function(){ alert(this.name); }};
> var obj2 = { name: 'obj2' };
> obj1.myFunc.apply(obj2, []); // obj2
>
> So the first argument of apply sets the scope, which is basically a
> fancy way of saying, tells it what to make "this" inside the function.
> The second argument of apply is an array, in which you can pass
> parameters. So:
>
> function myFunc(param1, param2, param3){
>   alert(this + ' is equal to ' + (param1 + param2 + param3));
>
> }
>
> myFunc.apply(12, [2,4,6]); // alerts "12 is equal to 12"
>
> I hope I answered your question, but I fear I may have just rambled at
> you. :(
>
> On Feb 25, 4:24 pm, Nic Hubbard  wrote:
>
> > Ha!  That worked perfectly!  Thanks, I really appreciate that, I was
> > lost.
>
> > So, could you explain, just so I know, what this did:
> > defaults.onComplete.apply(obj, []); ?
>
> > On Feb 25, 1:07 pm, Eric Garside  wrote:
>
> > > The problem is you're losing scope when calling onComplete. Try using
> > > the .apply method. Instead of:
>
> > > defaults.onComplete();
>
> > > try:
>
> > > defaults.onComplete.apply(obj.get(0), []);
>
> > > That should get "this" back to what you're expecting it to be. You
> > > could also skip a step and call:
>
> > > defaults.onComplete.apply(obj, []);
>
> > > ---
>
> > > onComplete: function(){ alert(this.attr('class')); }
>
> > > I'm pretty sure that should work. IF not, let me know, and I'll play
> > > around with it locally and actually test it out.
>
> > > On Feb 25, 3:52 pm, Nic Hubbard  wrote:
>
> > > > I was meaning when trying to call $(this) in the following
> > > > circumstance:
>
> > > >         $('a.matrixStatus').matrixStatus({
> > > >             urlSuffix: '?action=status_posting',
> > > >             onComplete: function() {alert('Callback worked'); alert($
> > > > (this).attr('class'));}
> > > >         });
>
> > > > When I am trying to pass things to the custom function, using $(this)
> > > > does not work.
>
> > > > On Feb 25, 12:28 pm, brian  wrote:
>
> > > > > Something like this? (no pun intended)
>
> > > > > obj.click(function() {
> > > > >   var self = $(this);
>
> > > > >   ...
>
> > > > >    defaults.onComplete(self);
>
> > > > > On Wed, Feb 25, 2009 at 3:11 PM, Nic Hubbard  
> > > > > wrote:
>
> > > > > > I have built a custom callback into my plugin, here is an example:
>
> > > > > >  $.fn.matrixStatus = function(options) {
> > > > > >    var defaults = {
> > > > > >      urlSuffix: '?action=live',
> > > > > >          onComplete: function() {}
> > > > > >    };
>
> > > > > >    var options = $.extend(defaults, options);
>
> > > > > >    return this.each(function() {
> > > > > >      var obj = $(this);
> > > > > >          var itemDesc = obj.attr('rel');
> > > > > >      var itemId = obj.attr('id');
> > > > > >      var itemHref = obj.attr('href');
> > > > > >      obj.click(function() {
> > > > > >      if (!itemDesc == '') {
> > > > > >                  var question = confirm('Are you sure you want to 
> > > > > > change the status
> > > > > > of "'+itemDesc+'"?');
> > > > > >          } else {
> > > > > >                  var question = confirm('Are you sure you want to 
> > > > > > change the
> > > > > > status?');
> > > > > >          }
> > > > > >        if (question) {
> > > > > >          $.ajax({
> > > > > >            type: 'POST',
> > > > > >            url: itemHref + defaults.urlSuffix
> > > > > >          });
>
> > > > > >                  // Run our custom callback
> > > > > >                  defaults.onComplete();
>
> > > > > >        }
> > > > > >        return false;
>
> > > > > >      });
>
> > > > > >    });
>
> > > > > >  };
>
> > > > > > For some reason when I try to use that function for a custom 
> > > > > > callback,
> > > > > > it won't allow me to get the jQuery object that the plugin is
> > > > > > targeting, so using $(this) within the onComplete function doesn't
> > > > > > work and 

[jQuery] Re: Can jquery do non stop effect?

2009-04-16 Thread Ricardo

It's quite easy:

var el = $('#mine');
var animateNonStop = function(){
   el.animate({ width:100 }).animate({width: 50 }, function(){
  animateNonStop();
   })
};
//start it up
animateNonStop();

which is similar to

var el = $('#mine');
(function(){
   el.animate({ width:100 }).animate({width: 50 }, function(){
  arguments.callee();
   });
})();

which can also be written as

$('#my').each(function(){
  var loop = arguments.callee;
  $(this)
.animate({ fontSize: '20px' })
.animate({ fontSize: '10px' }, function(){
  loop.call(this);
   })
});

cheers,
- ricardo

On Apr 16, 1:41 pm, carmit_levi  wrote:
> hi
> non stop effect for example if i want to design a "non -stop" coloring
> text but not with all color i want it to change from blue to red
> repeatedly
>
> look here
>
> http://rainbow.arch.scriptmania.com/
>
> do i have "non-stop" effects in jquery?
>
> the option to animate something repeatedly?
>
> like make the font bigger and smaller all the time?
>
> animate a text from red to yellow and orange all the time it is on
> show...
>
> tnx


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Joseph Le Brech

i think itll be covered in this.

http://stackoverflow.com/questions/224820/how-do-you-pass-arguments-to-anonymous-functions-in-javascript

> Date: Thu, 16 Apr 2009 14:46:41 -0700
> Subject: [jQuery] passing more than 1 param via click()?
> From: kgos...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> Hey all,
> 
> Not really sure how to ask this, so I'm sorry if my title is mis-
> leading. It is also why I wasn't able to find much searching, so I'm
> sorry if it's answered already.
> 
> Basically, the code I inherited was this:
> 
>   href="#drop"
>  class="edit-link"
>  onclick="
>   removeDept('','');
>   return false;"
> >Remove Department
> 
> And that is in an iteration, so the two values passed to the
> "removeDept" function are always dynamic.
> 
> I'm trying to handle this in the document.ready(). Normally, I throw
> the would-be dynamic param passed as a rel tag on an anchor, and
> that's how I retrieve things when I clean up code like this.
> 
> However, I'm scratching my head for the *best* way to handle this with
> the two params now... How do you guys recommend I handle something
> like that?
> 
> $(document).ready(function() {
>   $(".edit-link").click(function(){
>removeDept($(this).attr("rel"),$(this).attr("rel"));
>return false;
>   });
> });
> 
> 
> 
> Obviously I can't have two rel attributes :)
> 
> 
> Thanks in advance.

_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/

[jQuery] Re: how to streamline my code with Event Delegation?

2009-04-16 Thread mkmanning

You could put event delegation on the containing element, and then use
the target's index within its parent. From Andy's example this would
be:


link 01
link 02


$('linkContainer').click(function(e){
   var targ = $(e.target),
  index = $(this).find('a').index(targ)+1;
  $.get("myPage.asp",{
myVar: 'v'+(index<10?'0'+index:index)
},
function(data) {
$('#contentarea').html = data;
mySlideEffect();
}

});

On Apr 16, 2:23 pm, "Andy Matthews"  wrote:
> It would be more ideal to have some better way to identify each link. For
> example, assuming a similar structure:
>
> 
>         link 01
>         link 02
> 
>
> You might have this code:
>
> // all anchor tags inside the linkContainer
> $('#linkContainer a').click(function(e){
>         // prenvet the default link behaviour
>         e.preventDefault();
>         // get the text of the link, split on space, return the number
> portion
>         var target = 'v' + $(this).text().split(' ')[1];
>         // run the ajax call
>         $.get("myPage.asp",{
>                         myVar: target
>                 },
>                 function(data) {
>                         $('#contentarea').html = data;
>                         mySlideEffect();
>                 }
>         );
>
> });
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of redsun
> Sent: Thursday, April 16, 2009 2:29 PM
> To: jQuery (English)
> Subject: [jQuery] how to streamline my code with Event Delegation?
>
> i'm sure the jQuery i'm using below is very ineffiecient. the only syntax
> that changes are the numbers in the names of my IDs and my variables - and
> even they're matching. everything else is constant.
> i'm told that "event delegation" is the answer, but cant rewrite the code
> appropriately (i tried, but just made a mess of things - rookie).
>
> so could someone kindly show me how to streamline the the below with event
> delgation.
> thanks.
>
> jQuery:
>
>         $('#link01').click(function(){
>         $.get("myPage.asp", { myVar: "v01" },
>             function(data) {
>                 document.getElementById('contentarea').innerHTML = data;
>                 mySlideEffect(); });
>                 });
>
>         $('#link02').click(function(){
>         $.get("myPage.asp", { myVar: "v02" },
>             function(data) {
>                 document.getElementById('contentarea').innerHTML = data;
>                 mySlideEffect(); });
>                 });
>
>          etc. ...
>
>         $('#link99').click(function(){
>         $.get("myPage.asp", { myVar: "v99" },
>             function(data) {
>                 document.getElementById('contentarea').innerHTML = data;
>                 mySlideEffect(); });
>                 });
>
> HTML:
>
> page1
> page2
> ... etc ...
> page3
>
> 
> Loaded content slides in with this DIV.
> 


[jQuery] passing more than 1 param via click()?

2009-04-16 Thread kgosser

Hey all,

Not really sure how to ask this, so I'm sorry if my title is mis-
leading. It is also why I wasn't able to find much searching, so I'm
sorry if it's answered already.

Basically, the code I inherited was this:

','');
  return false;"
>Remove Department

And that is in an iteration, so the two values passed to the
"removeDept" function are always dynamic.

I'm trying to handle this in the document.ready(). Normally, I throw
the would-be dynamic param passed as a rel tag on an anchor, and
that's how I retrieve things when I clean up code like this.

However, I'm scratching my head for the *best* way to handle this with
the two params now... How do you guys recommend I handle something
like that?

$(document).ready(function() {
$(".edit-link").click(function(){
   removeDept($(this).attr("rel"),$(this).attr("rel"));
   return false;
});
});



Obviously I can't have two rel attributes :)


Thanks in advance.


[jQuery] Re: question about dealing with JSON callback

2009-04-16 Thread mkmanning

So you're saying JSON is not an object, it's a string? What does the O
stand for then? The OP gave this example JSON:

{
"product_id":"03",
"product_name":"Sample shoe",
"product_brand":"Shoe Brand",
"product_slug":"slug3",
"product_description":"description3",
"product_active":"1",
"product_type":"shoe",
"product_gender":"youth",
"product_sizes":"14",
"product_style":"style 3",
"product_categories":"3",
"product_shipping":"shipping 3",
"product_cost":"40.0",
"product_retail":"70.0"
}

In an ajax response with the reponse type as 'json' (or text and
eval'd yourself if you like), that's an object. It's composed of
name:value pairs. The names are strings. If you don't like what the
RFC says, take it up with Douglas Crockford.

On Apr 16, 2:25 pm, dhtml  wrote:
> On Apr 16, 12:42 am, mkmanning  wrote:
>
> > Just an FYI, but there's no 'object side' of the json in your example.
> > It just an object, consisting of name-value pairs. While you can leave
>
> No, it is not an object. It is a string.
>
> > quotes off of the names, they are strings which, according to the RFC,
> > should be quoted. Doing so will not cause problems, and will save you
> > from potentially running into a situation where your name conflicts
> > with one of the excessive number of reserved words.
>
> > On Apr 15, 7:05 pm, sneaks  wrote:
>
> > > the way i see it, there are quotes on the object side of the json
> > > where there should be no quotes...
>
> That makes about as much sense as something the OP would post.
>
> Garrett


[jQuery] Re: Where am I going wrong?

2009-04-16 Thread Rick

Thank you for posting that.. That is very interesting..

On Apr 16, 2:26 pm, mkmanning  wrote:
> What James said. This is one of those edge-cases that can ruin your
> day. If you look up the list of JavaScript reserved words, more than
> likely you won't see 'closed' on it, because it's not really a
> reserved word. It is however a property of the window object, and so
> only has a getter, not a setter, from your code. That's why it works
> inside the scope of your jQuery code, but fails when declared as a
> global var.
>
> On Apr 16, 2:18 pm, James  wrote:
>
> > I haven't looked into it deeply yet, but try changing "closed" to
> > another word, like "box_closed".
> > closed is a reserved word in Javascript so I think that might be
> > causing it.
>
> > On Apr 16, 10:44 am, Rick  wrote:
>
> > > It seems that having the var closed = false; outside of the function
> > > kills the code..
>
> > > Here is the page:http://client.vdhinc.com/cleardebtsolution/newsite/land/
>
> > > The code not working is on the First Name field.. I also put an
> > > example of the popup in the Last Name field so you can see what's
> > > happening when it works..
>
> > > On Apr 16, 1:29 pm, James  wrote:
>
> > > > The code looks fine. When you say that "nothing works", does that mean
> > > > even clicking the input field does not do the popup message?
> > > > Have you tried putting an alert in the click callback to see if it
> > > > executes?
>
> > > > Also, instead of click, you might want to consider using 'focus'.
> > > > Focus means the text cursor is in the field, whether the user clicked
> > > > into it or used the tab button on the keyboard to navigate to it. It's
> > > > a complement to blur, which is when the text cursor leaves the field.
>
> > > > On Apr 16, 8:49 am, Rick  wrote:
>
> > > > > I have this code:
>
> > > > > var closed = false;
> > > > > $(document).ready(function(){
> > > > >         $('#FirstName').click(function(){
> > > > >                 if (closed == false) {
> > > > >                         $('#popUpMessage').fadeIn('fast');
> > > > >                 }
> > > > >         });
> > > > >         $('#FirstName').blur(function(){
> > > > >                 $('#popUpMessage').fadeOut('slow');
> > > > >         })
> > > > >         $('#popUpMessageClose').click(function(){
> > > > >                 closed = true;
> > > > >                 $('#popUpMessage').fadeOut('slow');
> > > > >         })
>
> > > > > });
>
> > > > > As is, nothing works.. I have this on a field input like so...
>
> > > > >  > > > > maxlength="128" />
>
> > > > > when clicked it shows the hidden div "popUpMessage".. And on blur it
> > > > > hides it.. Inside that "popUpMessage" div I placed a small div for a
> > > > > close button named "popUpMessageClose".. What Im trying to do is hide
> > > > > that popUpMessage div permanently if the close div is clicked.. Any
> > > > > ideas where Im going wrong??


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech

The next guy "sucks", I saw ternary used in ruby so just looked it up on google.
I will use the [] for conditional execution, very educational.
It would probably need commenting, but if you know what it does, how it does it 
is only a google search away.

> Date: Thu, 16 Apr 2009 14:19:50 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: michaell...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> Guess it depends on who the next guy is :)
> 
> On Apr 16, 2:16 pm, "Andy Matthews"  wrote:
> > I'd be careful with code like that. It is terse, and very elegant, but not
> > all that readable from a "coding for the next guy" mentality.
> >
> >   _  
> >
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> > Behalf Of Joseph Le Brech
> > Sent: Thursday, April 16, 2009 4:12 PM
> > To: jquery-en@googlegroups.com
> > Subject: [jQuery] Re: Shorten the JQuery code
> >
> > I'm impressed by the [] brackets, does that eval() the 'hide' and 'show'
> > strings?
> >
> >
> >
> > > Date: Thu, 16 Apr 2009 14:08:09 -0700
> > > Subject: [jQuery] Re: Shorten the JQuery code
> > > From: michaell...@gmail.com
> > > To: jquery-en@googlegroups.com
> >
> > > $('#no-defs')[$('.def').length==0?'show':'hide']();
> >
> > > On Apr 16, 1:54 pm, MorningZ  wrote:
> > > > There isn't much you can do with that since you can't conditionally
> > > > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > > > false parameter and decide in the plugin, for instance
> >
> > > > $("#no_defs").conditionalShow($('.def').length == 0);
> >
> > > > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
> >
> > > > > Could someone tell me how to shorten the following code? Thanks.
> >
> > > > >   if ($('.def').length == 0) {
> > > > > $('#no-defs').show();
> > > > >   }
> > > > >   else {
> > > > > $('#no-defs').hide();
> > > > >   }
> >
> >   _  
> >
> > Surfing the web just got more rewarding. Download the New Internet Explorer
> > 8   

_
Beyond Hotmail — see what else you can do with Windows Live.
http://clk.atdmt.com/UKM/go/134665375/direct/01/

[jQuery] Re: Where am I going wrong?

2009-04-16 Thread mkmanning

What James said. This is one of those edge-cases that can ruin your
day. If you look up the list of JavaScript reserved words, more than
likely you won't see 'closed' on it, because it's not really a
reserved word. It is however a property of the window object, and so
only has a getter, not a setter, from your code. That's why it works
inside the scope of your jQuery code, but fails when declared as a
global var.

On Apr 16, 2:18 pm, James  wrote:
> I haven't looked into it deeply yet, but try changing "closed" to
> another word, like "box_closed".
> closed is a reserved word in Javascript so I think that might be
> causing it.
>
> On Apr 16, 10:44 am, Rick  wrote:
>
> > It seems that having the var closed = false; outside of the function
> > kills the code..
>
> > Here is the page:http://client.vdhinc.com/cleardebtsolution/newsite/land/
>
> > The code not working is on the First Name field.. I also put an
> > example of the popup in the Last Name field so you can see what's
> > happening when it works..
>
> > On Apr 16, 1:29 pm, James  wrote:
>
> > > The code looks fine. When you say that "nothing works", does that mean
> > > even clicking the input field does not do the popup message?
> > > Have you tried putting an alert in the click callback to see if it
> > > executes?
>
> > > Also, instead of click, you might want to consider using 'focus'.
> > > Focus means the text cursor is in the field, whether the user clicked
> > > into it or used the tab button on the keyboard to navigate to it. It's
> > > a complement to blur, which is when the text cursor leaves the field.
>
> > > On Apr 16, 8:49 am, Rick  wrote:
>
> > > > I have this code:
>
> > > > var closed = false;
> > > > $(document).ready(function(){
> > > >         $('#FirstName').click(function(){
> > > >                 if (closed == false) {
> > > >                         $('#popUpMessage').fadeIn('fast');
> > > >                 }
> > > >         });
> > > >         $('#FirstName').blur(function(){
> > > >                 $('#popUpMessage').fadeOut('slow');
> > > >         })
> > > >         $('#popUpMessageClose').click(function(){
> > > >                 closed = true;
> > > >                 $('#popUpMessage').fadeOut('slow');
> > > >         })
>
> > > > });
>
> > > > As is, nothing works.. I have this on a field input like so...
>
> > > >  > > > maxlength="128" />
>
> > > > when clicked it shows the hidden div "popUpMessage".. And on blur it
> > > > hides it.. Inside that "popUpMessage" div I placed a small div for a
> > > > close button named "popUpMessageClose".. What Im trying to do is hide
> > > > that popUpMessage div permanently if the close div is clicked.. Any
> > > > ideas where Im going wrong??


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Andy Matthews

Yep. I like it, and it's really nice...giving you more options. 

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of mkmanning
Sent: Thursday, April 16, 2009 4:20 PM
To: jQuery (English)
Subject: [jQuery] Re: Shorten the JQuery code


Guess it depends on who the next guy is :)

On Apr 16, 2:16 pm, "Andy Matthews"  wrote:
> I'd be careful with code like that. It is terse, and very elegant, but 
> not all that readable from a "coding for the next guy" mentality.
>
>   _
>
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] 
> On Behalf Of Joseph Le Brech
> Sent: Thursday, April 16, 2009 4:12 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Shorten the JQuery code
>
> I'm impressed by the [] brackets, does that eval() the 'hide' and 'show'
> strings?
>
>
>
> > Date: Thu, 16 Apr 2009 14:08:09 -0700
> > Subject: [jQuery] Re: Shorten the JQuery code
> > From: michaell...@gmail.com
> > To: jquery-en@googlegroups.com
>
> > $('#no-defs')[$('.def').length==0?'show':'hide']();
>
> > On Apr 16, 1:54 pm, MorningZ  wrote:
> > > There isn't much you can do with that since you can't 
> > > conditionally code in ".show" or ".hide" unless you made a plugin 
> > > to pass in a true/ false parameter and decide in the plugin, for 
> > > instance
>
> > > $("#no_defs").conditionalShow($('.def').length == 0);
>
> > > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > > > Could someone tell me how to shorten the following code? Thanks.
>
> > > >           if ($('.def').length == 0) {
> > > >             $('#no-defs').show();
> > > >           }
> > > >           else {
> > > >             $('#no-defs').hide();
> > > >           }
>
>   _
>
> Surfing the web just got more rewarding. Download the New Internet 
> Explorer
> 8   




[jQuery] Re: question about dealing with JSON callback

2009-04-16 Thread dhtml



On Apr 16, 12:42 am, mkmanning  wrote:
> Just an FYI, but there's no 'object side' of the json in your example.
> It just an object, consisting of name-value pairs. While you can leave

No, it is not an object. It is a string.

> quotes off of the names, they are strings which, according to the RFC,
> should be quoted. Doing so will not cause problems, and will save you
> from potentially running into a situation where your name conflicts
> with one of the excessive number of reserved words.
>
> On Apr 15, 7:05 pm, sneaks  wrote:
>
> > the way i see it, there are quotes on the object side of the json
> > where there should be no quotes...

That makes about as much sense as something the OP would post.

Garrett


[jQuery] Re: Where am I going wrong?

2009-04-16 Thread Rick

That did it! Thank you very much James..

On Apr 16, 2:18 pm, James  wrote:
> I haven't looked into it deeply yet, but try changing "closed" to
> another word, like "box_closed".
> closed is a reserved word in Javascript so I think that might be
> causing it.
>
> On Apr 16, 10:44 am, Rick  wrote:
>
> > It seems that having the var closed = false; outside of the function
> > kills the code..
>
> > Here is the page:http://client.vdhinc.com/cleardebtsolution/newsite/land/
>
> > The code not working is on the First Name field.. I also put an
> > example of the popup in the Last Name field so you can see what's
> > happening when it works..
>
> > On Apr 16, 1:29 pm, James  wrote:
>
> > > The code looks fine. When you say that "nothing works", does that mean
> > > even clicking the input field does not do the popup message?
> > > Have you tried putting an alert in the click callback to see if it
> > > executes?
>
> > > Also, instead of click, you might want to consider using 'focus'.
> > > Focus means the text cursor is in the field, whether the user clicked
> > > into it or used the tab button on the keyboard to navigate to it. It's
> > > a complement to blur, which is when the text cursor leaves the field.
>
> > > On Apr 16, 8:49 am, Rick  wrote:
>
> > > > I have this code:
>
> > > > var closed = false;
> > > > $(document).ready(function(){
> > > >         $('#FirstName').click(function(){
> > > >                 if (closed == false) {
> > > >                         $('#popUpMessage').fadeIn('fast');
> > > >                 }
> > > >         });
> > > >         $('#FirstName').blur(function(){
> > > >                 $('#popUpMessage').fadeOut('slow');
> > > >         })
> > > >         $('#popUpMessageClose').click(function(){
> > > >                 closed = true;
> > > >                 $('#popUpMessage').fadeOut('slow');
> > > >         })
>
> > > > });
>
> > > > As is, nothing works.. I have this on a field input like so...
>
> > > >  > > > maxlength="128" />
>
> > > > when clicked it shows the hidden div "popUpMessage".. And on blur it
> > > > hides it.. Inside that "popUpMessage" div I placed a small div for a
> > > > close button named "popUpMessageClose".. What Im trying to do is hide
> > > > that popUpMessage div permanently if the close div is clicked.. Any
> > > > ideas where Im going wrong??


[jQuery] Re: how to streamline my code with Event Delegation?

2009-04-16 Thread Andy Matthews

It would be more ideal to have some better way to identify each link. For
example, assuming a similar structure:


link 01
link 02


You might have this code:

// all anchor tags inside the linkContainer
$('#linkContainer a').click(function(e){
// prenvet the default link behaviour
e.preventDefault();
// get the text of the link, split on space, return the number
portion
var target = 'v' + $(this).text().split(' ')[1];
// run the ajax call
$.get("myPage.asp",{
myVar: target
},
function(data) {
$('#contentarea').html = data;
mySlideEffect();
}
);
});

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of redsun
Sent: Thursday, April 16, 2009 2:29 PM
To: jQuery (English)
Subject: [jQuery] how to streamline my code with Event Delegation?


i'm sure the jQuery i'm using below is very ineffiecient. the only syntax
that changes are the numbers in the names of my IDs and my variables - and
even they're matching. everything else is constant.
i'm told that "event delegation" is the answer, but cant rewrite the code
appropriately (i tried, but just made a mess of things - rookie).

so could someone kindly show me how to streamline the the below with event
delgation.
thanks.

jQuery:

$('#link01').click(function(){
$.get("myPage.asp", { myVar: "v01" },
function(data) {
document.getElementById('contentarea').innerHTML = data;
mySlideEffect(); });
});


$('#link02').click(function(){
$.get("myPage.asp", { myVar: "v02" },
function(data) {
document.getElementById('contentarea').innerHTML = data;
mySlideEffect(); });
});


 etc. ...


$('#link99').click(function(){
$.get("myPage.asp", { myVar: "v99" },
function(data) {
document.getElementById('contentarea').innerHTML = data;
mySlideEffect(); });
});


HTML:

page1
page2
... etc ...
page3



Loaded content slides in with this DIV.





[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Ricardo

That's already in the core :)

$('#no-defs').toggle( !$('.def').length );

http://docs.jquery.com/Effects/toggle#switch

- ricardo

On Apr 16, 5:54 pm, MorningZ  wrote:
> There isn't much you can do with that since you can't conditionally
> code in ".show" or ".hide" unless you made a plugin to pass in a true/
> false parameter and decide in the plugin, for instance
>
> $("#no_defs").conditionalShow($('.def').length == 0);
>
> On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > Could someone tell me how to shorten the following code? Thanks.
>
> >           if ($('.def').length == 0) {
> >             $('#no-defs').show();
> >           }
> >           else {
> >             $('#no-defs').hide();
> >           }


[jQuery] Re: CTRL+S to Insert Record PHP+JQUERY

2009-04-16 Thread Ricardo

Nice! Forget everything I said :)

I wasn't aware that you could override the browser shortcuts. This
means you can disable search, full-screen and other funcionalities in
FF, including cancelling Alt+F4 or Ctrl+W :O

On Apr 16, 3:06 pm, Nic Hubbard  wrote:
> http://jshotkeys.googlepages.com/test-static-01.html
>
> On Apr 15, 10:24 pm, bharani kumar 
> wrote:
>
> > Hi All ,
> > Can u please tell ,
>
> > How to implement  in jquery, php,,
>
> > Insert record after pressed the CTRL+S in keyboard ,
>
> > Thanks
>
> > --
> > உங்கள் நண்பன்
> > பரணி  குமார்
>
> > Regards
> > B.S.Bharanikumar
>
> > POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning

Guess it depends on who the next guy is :)

On Apr 16, 2:16 pm, "Andy Matthews"  wrote:
> I'd be careful with code like that. It is terse, and very elegant, but not
> all that readable from a "coding for the next guy" mentality.
>
>   _  
>
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> Behalf Of Joseph Le Brech
> Sent: Thursday, April 16, 2009 4:12 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Shorten the JQuery code
>
> I'm impressed by the [] brackets, does that eval() the 'hide' and 'show'
> strings?
>
>
>
> > Date: Thu, 16 Apr 2009 14:08:09 -0700
> > Subject: [jQuery] Re: Shorten the JQuery code
> > From: michaell...@gmail.com
> > To: jquery-en@googlegroups.com
>
> > $('#no-defs')[$('.def').length==0?'show':'hide']();
>
> > On Apr 16, 1:54 pm, MorningZ  wrote:
> > > There isn't much you can do with that since you can't conditionally
> > > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > > false parameter and decide in the plugin, for instance
>
> > > $("#no_defs").conditionalShow($('.def').length == 0);
>
> > > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > > > Could someone tell me how to shorten the following code? Thanks.
>
> > > >           if ($('.def').length == 0) {
> > > >             $('#no-defs').show();
> > > >           }
> > > >           else {
> > > >             $('#no-defs').hide();
> > > >           }
>
>   _  
>
> Surfing the web just got more rewarding. Download the New Internet Explorer
> 8   


[jQuery] Re: Where am I going wrong?

2009-04-16 Thread James

I haven't looked into it deeply yet, but try changing "closed" to
another word, like "box_closed".
closed is a reserved word in Javascript so I think that might be
causing it.

On Apr 16, 10:44 am, Rick  wrote:
> It seems that having the var closed = false; outside of the function
> kills the code..
>
> Here is the page:http://client.vdhinc.com/cleardebtsolution/newsite/land/
>
> The code not working is on the First Name field.. I also put an
> example of the popup in the Last Name field so you can see what's
> happening when it works..
>
> On Apr 16, 1:29 pm, James  wrote:
>
> > The code looks fine. When you say that "nothing works", does that mean
> > even clicking the input field does not do the popup message?
> > Have you tried putting an alert in the click callback to see if it
> > executes?
>
> > Also, instead of click, you might want to consider using 'focus'.
> > Focus means the text cursor is in the field, whether the user clicked
> > into it or used the tab button on the keyboard to navigate to it. It's
> > a complement to blur, which is when the text cursor leaves the field.
>
> > On Apr 16, 8:49 am, Rick  wrote:
>
> > > I have this code:
>
> > > var closed = false;
> > > $(document).ready(function(){
> > >         $('#FirstName').click(function(){
> > >                 if (closed == false) {
> > >                         $('#popUpMessage').fadeIn('fast');
> > >                 }
> > >         });
> > >         $('#FirstName').blur(function(){
> > >                 $('#popUpMessage').fadeOut('slow');
> > >         })
> > >         $('#popUpMessageClose').click(function(){
> > >                 closed = true;
> > >                 $('#popUpMessage').fadeOut('slow');
> > >         })
>
> > > });
>
> > > As is, nothing works.. I have this on a field input like so...
>
> > >  > > maxlength="128" />
>
> > > when clicked it shows the hidden div "popUpMessage".. And on blur it
> > > hides it.. Inside that "popUpMessage" div I placed a small div for a
> > > close button named "popUpMessageClose".. What Im trying to do is hide
> > > that popUpMessage div permanently if the close div is clicked.. Any
> > > ideas where Im going wrong??


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning

show() and hide() are methods of the jQuery object, so they're
accessible with both dot and bracket notation as with any method or
attribute of an object.

On Apr 16, 2:12 pm, Joseph Le Brech  wrote:
> I'm impressed by the [] brackets, does that eval() the 'hide' and 'show' 
> strings?
>
>
>
> > Date: Thu, 16 Apr 2009 14:08:09 -0700
> > Subject: [jQuery] Re: Shorten the JQuery code
> > From: michaell...@gmail.com
> > To: jquery-en@googlegroups.com
>
> > $('#no-defs')[$('.def').length==0?'show':'hide']();
>
> > On Apr 16, 1:54 pm, MorningZ  wrote:
> > > There isn't much you can do with that since you can't conditionally
> > > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > > false parameter and decide in the plugin, for instance
>
> > > $("#no_defs").conditionalShow($('.def').length == 0);
>
> > > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > > > Could someone tell me how to shorten the following code? Thanks.
>
> > > >           if ($('.def').length == 0) {
> > > >             $('#no-defs').show();
> > > >           }
> > > >           else {
> > > >             $('#no-defs').hide();
> > > >           }
>
> _
> View your Twitter and Flickr updates from one place – Learn 
> more!http://clk.atdmt.com/UKM/go/137984870/direct/01/


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread MorningZ

$('#no-defs')[$('.def').length==0?'show':'hide']();

Whoa

so

$("...")["show"]()
is equiv
$("...").show()

that kinda makes sense thinking about the way arrays work in JS..
slick

On Apr 16, 5:08 pm, mkmanning  wrote:
> $('#no-defs')[$('.def').length==0?'show':'hide']();
>
> On Apr 16, 1:54 pm, MorningZ  wrote:
>
> > There isn't much you can do with that since you can't conditionally
> > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > false parameter and decide in the plugin, for instance
>
> > $("#no_defs").conditionalShow($('.def').length == 0);
>
> > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > > Could someone tell me how to shorten the following code? Thanks.
>
> > >           if ($('.def').length == 0) {
> > >             $('#no-defs').show();
> > >           }
> > >           else {
> > >             $('#no-defs').hide();
> > >           }


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Andy Matthews
I'd be careful with code like that. It is terse, and very elegant, but not
all that readable from a "coding for the next guy" mentality.
 

  _  

From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Joseph Le Brech
Sent: Thursday, April 16, 2009 4:12 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Shorten the JQuery code


I'm impressed by the [] brackets, does that eval() the 'hide' and 'show'
strings?

> Date: Thu, 16 Apr 2009 14:08:09 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: michaell...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> $('#no-defs')[$('.def').length==0?'show':'hide']();
> 
> On Apr 16, 1:54 pm, MorningZ  wrote:
> > There isn't much you can do with that since you can't conditionally
> > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > false parameter and decide in the plugin, for instance
> >
> > $("#no_defs").conditionalShow($('.def').length == 0);
> >
> > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
> >
> > > Could someone tell me how to shorten the following code? Thanks.
> >
> > >   if ($('.def').length == 0) {
> > > $('#no-defs').show();
> > >   }
> > >   else {
> > > $('#no-defs').hide();
> > >   }


  _  

Surfing the web just got more rewarding. Download the New Internet Explorer
8   


[jQuery] Re: Wrapping p siblings following h1 in divs

2009-04-16 Thread Claes H

On Thu, Mar 26, 2009 at 4:01 AM, Ricardo  wrote:
>
> jQuery.fn.nextUntil = function(expr) {
>   var match = [];
>   this.each(function(){
>       for( var i = this.nextSibling; i; i = i.nextSibling ) {
>           if ( i.nodeType != 1 ) continue;
>           if ( jQuery.filter( expr, [i] ).r.length ) break;
>           match.push( i );
>       }
>   });
>   return this.pushStack( match, arguments );
> };
> (plugin by John Resig)
>
> $('h1').each(function(){
>  $(this).nextUntil('h1').wrapAll('div');
> });
>

Thanks for your answer. I missed this answer unfortunately, and first
today returned to this problem. Without seeing your reply I solved it
without jquery as follows:

var headerList = document.getElementsByTagName("h1");
for (var i = 0; i < headerList.length; i++) {
if (i == headerList.length) {
break;
}
var header = headerList[i];
var nextHeader = headerList[i+1];
var nextSibling = header.nextSibling;
var div = document.createElement('div');
div.id = "div-" + header.id;
header.parentNode.replaceChild(div, header);
div.appendChild(header);
while (nextSibling != nextHeader) {
var tmpSibling = nextSibling.nextSibling;
var tmpParent = nextSibling.parentNode;
tmpParent.removeChild(nextSibling);
div.appendChild(nextSibling);
nextSibling = tmpSibling;
}
}

Thanks for taking the time to answer

/Claes


[jQuery] DT selector not applying to last DT in DL tag on IE7

2009-04-16 Thread Reno

I have a definition list () and i'm adding a click
function to each  tag in the list.  There are about 6 or 7  pairs in the list.

For some reason in IE7, the click function i've made does not apply to
the last  tag in the list.  Can anyone explain why?



Here is my javascript code:

$(document).ready(function () {
//Toggle Faq Answers
$(".faqList dd").hide();
$(".faqList dt").add("dd").append("").end
().click(function(){
$(".faqList 
dt.isopen").removeClass("isopen").find("span").toggle
(300).end().next().toggle(300);
$(this).addClass("isopen").find("span").toggle(300).end().next
().toggle(300);
});

});

If you need more info please let me know.  Thank You.


[jQuery] Autocomplete problems with multiple fields

2009-04-16 Thread Lance A. Brown

Greetings,

I'm working on adding autocomplete to a form which describes a
discussion paper.  Each paper can have multiple authors and I want to
provide autocomplete on the author names.  I'm new to jQuery so this
code is kind of rough.

My java script is:

// Begin
function parse_search(data) {
  var result = [];
  for (var i = 0; i < data.names.length; i++) {
result[i] = { data: data.names[i].name,
  value: data.names[i].id,
  result: data.names[i].name
};
  }
  return result;
}

function  format_item(row, i, max) {
  return row;
}

function set_author_autocomplete()
{
  var searchurl = $("#authsearch_url").attr("href");

  $(".author_name").each(function (i) {
   $(this).autocomplete(searchurl, {
dataType: 'json',
parse: parse_search,
formatItem: format_item
}
)
 }
 );
}



$(document).ready(set_author_autocomplete);
//End


The corresponding snippet of HTML is:



Authors (list in order)
 Author names must be entered in proper format
such that BibTeX 0.99 will parse them correctly.  'Last, Suffix,
First' is required for use with suffixes. 
 To remove an author, empty the corresponding
field. Leave it blank. 






Author









This works fine with just _one_ author listed.  If I use this exact same
pattern on a web page with multiple authors listed, such as this html
snippet:



Authors (list in order)
 Author names must be entered in proper format
such that BibTeX 0.99 will parse them correctly.  'Last, Suffix,
First' is required for use with suffixes. 
 To remove an author, empty the corresponding
field. Leave it blank. 






Author








Author








Author






The autocomplete doesn't work right.  Firebug indicates the autocomplete
is added to the fields, evidenced by the ac_input class being added to
each of the input fields, but I receive the following error when I start
typing:

[Exception... "'JavaScript component does not have a method named:
"handleEvent"' when calling method: [nsIDOMEventListener::handleEvent]"
 nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"
location: ""  data: no]
http://www.stat.duke.edu/research/wp/assets/js/jquery.js
Line 1296
[Exception... "'JavaScript component does not have a method named:
"handleEvent"' when calling method: [nsIDOMEventListener::handleEvent]"
 nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"
location: ""  data: no]
Line 0

I'm new to Javascripting and at a total loss.  Any assistance would be
appreciated.

--[Lance]

-- 
 GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9
 CACert.org Assurer


[jQuery] how to streamline my code with Event Delegation?

2009-04-16 Thread redsun

i'm sure the jQuery i'm using below is very ineffiecient. the only
syntax that changes are the numbers in the names of my IDs and my
variables - and even they're matching. everything else is constant.
i'm told that "event delegation" is the answer, but cant rewrite the
code appropriately (i tried, but just made a mess of things -
rookie).

so could someone kindly show me how to streamline the the below with
event delgation.
thanks.

jQuery:

$('#link01').click(function(){
$.get("myPage.asp", { myVar: "v01" },
function(data) {
document.getElementById('contentarea').innerHTML =
data;
mySlideEffect(); });
});


$('#link02').click(function(){
$.get("myPage.asp", { myVar: "v02" },
function(data) {
document.getElementById('contentarea').innerHTML =
data;
mySlideEffect(); });
});


 etc. ...


$('#link99').click(function(){
$.get("myPage.asp", { myVar: "v99" },
function(data) {
document.getElementById('contentarea').innerHTML =
data;
mySlideEffect(); });
});


HTML:

page1
page2
... etc ...
page3



Loaded content slides in with this DIV.



[jQuery] Autocomplete: Problem putting autocomplete on multiple fields

2009-04-16 Thread labrown

Greetings,

I'm working on adding autocomplete to a form which describes a
discussion paper.  Each paper can have multiple authors and I want to
provide autocomplete on the author names.  I'm new to jQuery so this
code is kind of rough.

In the head section of the page I load the necessary js files:
http://xxx/research/wp/assets/css/
form.css" type="text/css"/>
http://xxx/research/wp/assets/css/
jquery.autocomplete.css" type="text/css"/>
http://xxx/research/wp/assets/js/jquery.js"; type="text/
javascript">
http://xxx/research/wp/assets/js/jquery.bgiframe.min.js";
type="text/javascript">
http://xxx/research/wp/assets/js/jquery.ajaxQueue.js";
type="text/javascript">
http://xxxresearch/wp/assets/js/jquery.autocomplete.js";
type="text/javascript">
http://xxx/research/wp/assets/js/author_autocomplete.js";
type="text/javascript">

author_autocomplete.js is:
// Begin
function parse_search(data) {
  var result = [];
  for (var i = 0; i < data.names.length; i++) {
result[i] = { data: data.names[i].name,
  value: data.names[i].id,
  result: data.names[i].name
};
  }
  return result;
}

function  format_item(row, i, max) {
  return row;
}

function set_author_autocomplete()
{
  var searchurl = $("#authsearch_url").attr("href");

  $(".author_name").each(function (i) {
   $(this).autocomplete(searchurl, {
dataType: 'json',
parse:
parse_search,
formatItem:
format_item
}
)
 }
 );
}



$(document).ready(set_author_autocomplete);
//End

The corresponding snippet of HTML is:


Authors (list in order)
 Author names must be entered in proper format
such that BibTeX 0.99 will parse them correctly.  'Last, Suffix,
First' is required for use with suffixes. 
 To remove an author, empty the corresponding
field. Leave it blank. 






Author






This works fine with just _one_ author listed.  If I use this exact
same pattern on a web page with multiple authors listed, such as this
html snippet:


Authors (list in order)
 Author names must be entered in proper format
such that BibTeX 0.99 will parse them correctly.  'Last, Suffix,
First' is required for use with suffixes. 
 To remove an author, empty the corresponding
field. Leave it blank. 






Author








Author








Author





The autocomplete doesn't work right.  Firebug indicates the
autocomplete is added to the fields, evidenced by the ac_input class
being added to each of the input fields, but I receive the following
error when I start typing:

[Exception... "'JavaScript component does not have a method named:
"handleEvent"' when calling method:
[nsIDOMEventListener::handleEvent]"  nsresult: "0x80570030
(NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"  location: ""
data: no]
http://www.stat.duke.edu/research/wp/assets/js/jquery.js
Line 1296
[Exception... "'JavaScript component does not have a method named:
"handleEvent"' when calling method:
[nsIDOMEventListener::handleEvent]"  nsresult: "0x80570030
(NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"  location: ""
data: no]
Line 0

I'm new to Javascripting and at a total loss.  Any assistance would be
appreciated.

--[Lance]


[jQuery] Little problem using jEditable

2009-04-16 Thread Hugo

Little problem using jEditable: I use jEditable on a paragraph and my
PHP file successfully updates the database upon submission. But after
I click the OK button or press enter when I 'jEdit' such a paragraph,
the content of the paragraph always changes to 'Click to edit', no
matter what I entered in the input area. After I reloaded the page I
can see that the database was succesfully updated: the paragraph shows
the updated text.

Here's some code:

The main file:



$(document).ready(function() {
$('.poster').editable('editajax.php', {
name : 'pCont',
id : 'idee',
submit : 'OK',
cancel : 'Cancel'
});
});


Also in the main file:
" . $post['Post_Title'] . "";
echo "" . $post
['Post_Content'] . "";
}
?>


editajax.php:
".$pCont."";
return $rett;
?>

On that last thing: I also tried returning $pCont without the
paragraph tags, doesn't make any difference.

So a short summary of my situation: jEditable works as it should,
except for one thing: after I click OK and submit the form, it does
not display the updated text on the page but 'Click to edit' is all it
says.

Could anybody help me?

Thank you very much in advance.

Kind regards,


[jQuery] Help with .load(), strips script tags

2009-04-16 Thread bob.nel...@gmail.com

Hi all, I'm relatively new to jQuery and I've run across an issue.
When I use the .load() function to inject a page into the DOM, the

[jQuery] Re: Scope of the (AJAX) callback functions

2009-04-16 Thread tarini




Brice Burgess wrote:
> 
> 
>   formVar is undefinded. I'm not sure if jQuery has a "bind" like 
> prototype does to handle this?
> 
> 


I wrote this plugin, I think it will be useful

http://code.google.com/p/jquerycallback/
-- 
View this message in context: 
http://www.nabble.com/Scope-of-the-%28AJAX%29-callback-functions-tp5148004s27240p23086350.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Can jquery do non stop effect?

2009-04-16 Thread carmit_levi


hi
non stop effect for example if i want to design a "non -stop" coloring
text but not with all color i want it to change from blue to red
repeatedly

look here

http://rainbow.arch.scriptmania.com/

do i have "non-stop" effects in jquery?

the option to animate something repeatedly?

like make the font bigger and smaller all the time?

animate a text from red to yellow and orange all the time it is on
show...

tnx



[jQuery] tabs collapsed by default on open

2009-04-16 Thread robintrain...@yahoo.com

Hello everyone. Is there a way to have tabs created in jQuery that are
collapsed when the page loads? I use this:

$(document).ready(function(){
$("#tabs").tabs({ collapsible: true
});
});

to allow the user to click on the tab to collapse it once the page
loads. But how do I get the tab content to be hidden to begin with?

Thanks very much,

Robin

HTML for TABS



One
Two

   

   Content for tab 1


   Content for tab 2



CSS for TABS

 
  .ui-tabs { padding: .2em; zoom: 1; }
.ui-tabs .ui-tabs-nav { list-style: none; position: relative;
padding: .2em .2em 0; }
.ui-tabs .ui-tabs-nav li { float: left; border-bottom-width: 1 !
important; margin: 0 .2em -1px 0; padding: 0; }
.ui-tabs .ui-tabs-nav li a { float: left; text-decoration: none;
padding: .5em 1em; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 1px;
border-bottom-width: 1; background-color:#ff; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav
li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a
{ cursor: text; }
.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav
li.ui-tabs-selected a { cursor: pointer; } /* first selector in group
seems obsolete, but required to overcome bug in Opera applying cursor:
text overall if defined elsewhere... */
.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border-
width: 1; background-color: #cc; float:left; width: 500px; }
.ui-tabs .ui-tabs-hide { display: none !important; }

  


[jQuery] jquery form plugin not working in IE8

2009-04-16 Thread adaa

I'm using http://malsup.com/jquery/form  plugin but it is not working
on IE8 but all other browsers. Pls help..

thanks
adnan


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech

I'm impressed by the [] brackets, does that eval() the 'hide' and 'show' 
strings?

> Date: Thu, 16 Apr 2009 14:08:09 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: michaell...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> $('#no-defs')[$('.def').length==0?'show':'hide']();
> 
> On Apr 16, 1:54 pm, MorningZ  wrote:
> > There isn't much you can do with that since you can't conditionally
> > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > false parameter and decide in the plugin, for instance
> >
> > $("#no_defs").conditionalShow($('.def').length == 0);
> >
> > On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
> >
> > > Could someone tell me how to shorten the following code? Thanks.
> >
> > >   if ($('.def').length == 0) {
> > > $('#no-defs').show();
> > >   }
> > >   else {
> > > $('#no-defs').hide();
> > >   }

_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning

$('#no-defs')[$('.def').length==0?'show':'hide']();

On Apr 16, 1:54 pm, MorningZ  wrote:
> There isn't much you can do with that since you can't conditionally
> code in ".show" or ".hide" unless you made a plugin to pass in a true/
> false parameter and decide in the plugin, for instance
>
> $("#no_defs").conditionalShow($('.def').length == 0);
>
> On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
>
> > Could someone tell me how to shorten the following code? Thanks.
>
> >           if ($('.def').length == 0) {
> >             $('#no-defs').show();
> >           }
> >           else {
> >             $('#no-defs').hide();
> >           }


[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech

or try

ndfs=$('#no-defs');($('.def').length == 0) ? ndfs.show() : ndfs.hide();

> Date: Thu, 16 Apr 2009 13:54:07 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: morni...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> There isn't much you can do with that since you can't conditionally
> code in ".show" or ".hide" unless you made a plugin to pass in a true/
> false parameter and decide in the plugin, for instance
> 
> $("#no_defs").conditionalShow($('.def').length == 0);
> 
> 
> 
> On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
> > Could someone tell me how to shorten the following code? Thanks.
> >
> >   if ($('.def').length == 0) {
> > $('#no-defs').show();
> >   }
> >   else {
> > $('#no-defs').hide();
> >   }

_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread MorningZ

There isn't much you can do with that since you can't conditionally
code in ".show" or ".hide" unless you made a plugin to pass in a true/
false parameter and decide in the plugin, for instance

$("#no_defs").conditionalShow($('.def').length == 0);



On Apr 16, 4:27 pm, Dragon-Fly999  wrote:
> Could someone tell me how to shorten the following code? Thanks.
>
>           if ($('.def').length == 0) {
>             $('#no-defs').show();
>           }
>           else {
>             $('#no-defs').hide();
>           }


[jQuery] Re: Where am I going wrong?

2009-04-16 Thread Rick

It seems that having the var closed = false; outside of the function
kills the code..

Here is the page: http://client.vdhinc.com/cleardebtsolution/newsite/land/

The code not working is on the First Name field.. I also put an
example of the popup in the Last Name field so you can see what's
happening when it works..

On Apr 16, 1:29 pm, James  wrote:
> The code looks fine. When you say that "nothing works", does that mean
> even clicking the input field does not do the popup message?
> Have you tried putting an alert in the click callback to see if it
> executes?
>
> Also, instead of click, you might want to consider using 'focus'.
> Focus means the text cursor is in the field, whether the user clicked
> into it or used the tab button on the keyboard to navigate to it. It's
> a complement to blur, which is when the text cursor leaves the field.
>
> On Apr 16, 8:49 am, Rick  wrote:
>
> > I have this code:
>
> > var closed = false;
> > $(document).ready(function(){
> >         $('#FirstName').click(function(){
> >                 if (closed == false) {
> >                         $('#popUpMessage').fadeIn('fast');
> >                 }
> >         });
> >         $('#FirstName').blur(function(){
> >                 $('#popUpMessage').fadeOut('slow');
> >         })
> >         $('#popUpMessageClose').click(function(){
> >                 closed = true;
> >                 $('#popUpMessage').fadeOut('slow');
> >         })
>
> > });
>
> > As is, nothing works.. I have this on a field input like so...
>
> >  > maxlength="128" />
>
> > when clicked it shows the hidden div "popUpMessage".. And on blur it
> > hides it.. Inside that "popUpMessage" div I placed a small div for a
> > close button named "popUpMessageClose".. What Im trying to do is hide
> > that popUpMessage div permanently if the close div is clicked.. Any
> > ideas where Im going wrong??


[jQuery] Re: Calling a function from a non-jQuery .JS file

2009-04-16 Thread kiusau

> document.ElementById has a bug in ie6 and ie7 that will return an
> element with a name attribute of the same value.  Use $('#today')
> instead.

Got it. Thanks!

> todayEl.innerHTML = "something" can cause memory leaks if events are
> added to DOM objects inside of todayEl and then just written over
> instead of being removed first.  Use $('#today').html(formatDate(new
> Date)); instead if this could be a cause for concern.

Are you saying that innerHTML is not reusable for the same selector,
or that it can only be used once in the same document. I am a little
confused.  Did you know that W3 is promoting it?

http://dev.w3.org/html5/html4-differences/Overview.html#htmldocument-extensions

Roddy


[jQuery] Re: Where am I going wrong?

2009-04-16 Thread James

The code looks fine. When you say that "nothing works", does that mean
even clicking the input field does not do the popup message?
Have you tried putting an alert in the click callback to see if it
executes?

Also, instead of click, you might want to consider using 'focus'.
Focus means the text cursor is in the field, whether the user clicked
into it or used the tab button on the keyboard to navigate to it. It's
a complement to blur, which is when the text cursor leaves the field.

On Apr 16, 8:49 am, Rick  wrote:
> I have this code:
>
> var closed = false;
> $(document).ready(function(){
>         $('#FirstName').click(function(){
>                 if (closed == false) {
>                         $('#popUpMessage').fadeIn('fast');
>                 }
>         });
>         $('#FirstName').blur(function(){
>                 $('#popUpMessage').fadeOut('slow');
>         })
>         $('#popUpMessageClose').click(function(){
>                 closed = true;
>                 $('#popUpMessage').fadeOut('slow');
>         })
>
> });
>
> As is, nothing works.. I have this on a field input like so...
>
>  maxlength="128" />
>
> when clicked it shows the hidden div "popUpMessage".. And on blur it
> hides it.. Inside that "popUpMessage" div I placed a small div for a
> close button named "popUpMessageClose".. What Im trying to do is hide
> that popUpMessage div permanently if the close div is clicked.. Any
> ideas where Im going wrong??


[jQuery] Shorten the JQuery code

2009-04-16 Thread Dragon-Fly999

Could someone tell me how to shorten the following code? Thanks.

  if ($('.def').length == 0) {
$('#no-defs').show();
  }
  else {
$('#no-defs').hide();
  }


[jQuery] Re: jQuery Cycle with Transparent GIFs...Works in FF, Safari...but not in IE

2009-04-16 Thread Andy Matthews

Well your first problem is using GIF files for those photographs in the
first place. Photographs should ALWAYS be JPG files, or PNG if you need
transparency. You can really notice the pixelation on the back end of the
Ferrari, and the sides of the yellow and orange station wagon.

But as for your issue, I see no problem with your slideshow in IE7. Which
portion should we be looking at?


Andy matthews

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Matt M.
Sent: Thursday, April 16, 2009 2:07 PM
To: jQuery (English)
Subject: [jQuery] jQuery Cycle with Transparent GIFs...Works in FF,
Safari...but not in IE


Hello,

I was wondering if anyone knew of a solution to be able to use transparent
.GIFs with the malsup Cycle plugin. The implementation works in Firefox,
Safari, but the images show up with a white background in IE 7. Here's the
link to a live version...

http://www.speedwaremotorsports.com/new-home

Thanks for any help!

--Matt




[jQuery] Re: jQuery Cycle with Transparent GIFs...Works in FF, Safari...but not in IE

2009-04-16 Thread Matt M.

I solved this one. I had to use these options:

cleartype:  false,
cleartypeNoBg: false

Works nicely. Thanks to Mike Alsup for a great plugin!


On Apr 16, 12:06 pm, "Matt M."  wrote:
> Hello,
>
> I was wondering if anyone knew of a solution to be able to use
> transparent .GIFs with the malsup Cycle plugin. The implementation
> works in Firefox, Safari, but the images show up with a white
> background in IE 7. Here's the link to a live version...
>
> http://www.speedwaremotorsports.com/new-home
>
> Thanks for any help!
>
> --Matt


[jQuery] Re: Too much recusion/Out of Memory

2009-04-16 Thread Eyveneena



Hi All,

   I thought I needed to upgrade or somethingit only happens in IE 8 for
me and I usually do not put my script in the header section of my page until
todayToday was the first time I experienced the error line 41 out of
memory...?

Eyveneena
www.lifesmem.com
-- 
View this message in context: 
http://www.nabble.com/Too-much-recusion-Out-of-Memory-tp22853731s27240p23084834.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Kean

@Josh Powell
- string concatenation is plenty fast 99% of the time and a lot more
readable.
Yes string concatenation is more readable and 99% faster for normal
usage. But looping and concatenate a huge chunk in this particular
case is slower. Reason: every + between 2 strings returns a new string
before concatenating with other strings. Array.prototype.join does not
have that problem. You just need more than 6 string concatenation
(subject to string length and debate) and it will be a good choice for
Array.prototype.join to take over.

- W3C DOM Node creation is much slower then inserting via innerHTML,
especially as you add more nodes.  It doesn't matter how fast the
nodes are created, it will always be slower to create, adjust, and
insert 10,000 nodes then one string.
That's old school thinking. Please refer to my original post, I am
talking about Chrome's v8 engine and browser detection. You will be
pleasantly surprised. See RobG's comment too.

@RobG
Thanks for benchmarking.


[jQuery] jQuery Cycle with Transparent GIFs...Works in FF, Safari...but not in IE

2009-04-16 Thread Matt M.

Hello,

I was wondering if anyone knew of a solution to be able to use
transparent .GIFs with the malsup Cycle plugin. The implementation
works in Firefox, Safari, but the images show up with a white
background in IE 7. Here's the link to a live version...

http://www.speedwaremotorsports.com/new-home

Thanks for any help!

--Matt


[jQuery] clueTip access to xhr

2009-04-16 Thread zendog74

I am successfully using clueTip to make ajax requests that return
either xml or json and populate the tooltips. It is working great.
However, I am trying to make my code more sophisticated to handle
exceptions and I need access to the xhr to do that properly. I have
been unable to find a way to get access to the xhr using clueTip,
especially in the ajaxProcess function. Is there a way to do this?

Here is what I am trying to do:

ajaxProcess: function(xhr, data) {
return checkResponse(xhr.status, data);
}

//Pseudo-code
function checkHttpStatusCode(statusCode, data){
  //Check the status code and send back the error message in the
returned xml packet if there is one.

}


[jQuery] Re: Selector questions

2009-04-16 Thread Dragon-Fly999

I didn't know about the closest method and I could use it in my case.
Thank you.

On Apr 16, 8:33 am, Leonardo K  wrote:
> Maybe is easier if you put a class (wrapper) in your div that wrap all other
> divs, and then you could use:
>
> $(this).closest('div.wrapper').find(":checkbox");
>
> and
>
> $(this).closest('div.wrapper').prev();
>
> On Thu, Apr 16, 2009 at 09:26, Dragon-Fly999 wrote:
>
>
>
> > Thanks, Karl.  Your suggestions work fine.  I just started using
> > JQuery and found the selectors very powerful.  I was wondering if the
> > selectors that you suggested can be less dependent on the number of
> > divs in that section of the HTML.
>
> > Instead of using "$(this).parent().parent().find(':checkbox')", is
> > there a way to select using the following rule:
> > Go up the hierarchy (regardless of how many parents there are) until
> > the first  is found, then give me a list of all the checkboxes that
> > are the descendants of the  right after the .
>
> > Similarly, instead of using "$(this).parent().parent().prev()", is
> > there a way to select using the following rule:
> > Go up the hierarchy (regardless of how many parents there are) and
> > return the first .
>
> > The reason that I asked these questions is because I can see myself
> > adding more 's in that section of the HTML.
>
> > On Apr 15, 10:31 pm, Karl Swedberg  wrote:
> > > On Apr 15, 2009, at 6:24 PM, Dragon-Fly999 wrote:
>
> > > > Hi, I have a couple of questions about selectors.  I have the
> > > > following HTML:
>
> > > > =
>
> > > > Some  elements and  elements here.
> > > > ...
> > > > ...
>
> > > > Information Type 1
> > > > 
> > > >  
> > > > > > > for="first">First
> > > >  
> > > >  
> > > > > > > for="mid">Middle
> > > >  
> > > >  
> > > > > > > for="last">Last
> > > >  
> > > > 
>
> > > > ...
> > > > ...
> > > > More  elements and  elements here.
>
> > > > =
>
> > > > Question 1:
> > > > In the click handler of the first checkbox, I would like to get the
> > > > first, middle, and last checkboxes (but not the other checkboxes on
> > > > the page). What selector should I use?
>
> > > There are a number of options, but this will do the trick:
>
> > > $(this).parent().parent().find(':checkbox')
>
> > > > Question 2:
> > > > In the click handler of the first checkbox, I would like to get the
> > > > first  element that it finds traversing up the hierarchy (i.e. the
> > > >  with id="info-1-heading").  What selector should I use?
>
> > > > Thank you.
>
> > > $(this).parent().parent().prev()
>
> > > or combined:
>
> > > $
> > > (this
> > > ).parent
> > > ().parent
> > > ().find(':checkbox').doSomething().end().prev().doSomethingElse();
>
> > > and a bit more readable:
>
> > > $(this)
> > >.parent()
> > >  .parent()
> > >.find(':checkbox').doSomething()
> > >  .end()
> > >.prev().doSomethingElse();
>
> > > --Karl
>
> > > 
> > > Karl Swedbergwww.englishrules.comwww.learningjquery.com


[jQuery] Where am I going wrong?

2009-04-16 Thread Rick

I have this code:

var closed = false;
$(document).ready(function(){
$('#FirstName').click(function(){
if (closed == false) {
$('#popUpMessage').fadeIn('fast');
}
});
$('#FirstName').blur(function(){
$('#popUpMessage').fadeOut('slow');
})
$('#popUpMessageClose').click(function(){
closed = true;
$('#popUpMessage').fadeOut('slow');
})
});

As is, nothing works.. I have this on a field input like so...



when clicked it shows the hidden div "popUpMessage".. And on blur it
hides it.. Inside that "popUpMessage" div I placed a small div for a
close button named "popUpMessageClose".. What Im trying to do is hide
that popUpMessage div permanently if the close div is clicked.. Any
ideas where Im going wrong??


[jQuery] Re: Creating an ajax status

2009-04-16 Thread Nic Hubbard

I got this working, thanks guys.

On Apr 16, 10:19 am, Donny Kurnia  wrote:
> Nic Hubbard wrote:
> > I have a number of GET and POST ajax calls that do various things my
> > script.  For each one, I would like to set a status that is a string,
> > so that I can out put that to the user.  So, it might look like this:
>
> > Ajax POST
> > Posting to page
>
> > Ajax GET
> > Getting content page
>
> > Ajax POST
> > Sending data to page
>
> > Basically I want to set the status using something like $
> > ('#status_div').text(); so that the user will see the status text when
> > each ajax function is run.
>
> > Does anyone have ideas on how this could be accomplished?
>
> This is what I used to do:
>
> 1. In the click function handler, put the loading text and image to the
> status placeholder.
> $('#status_div').html(' Loading ...');
>
> 2. Call the ajax
>
> 3. In the ajax callbak function, I update the status placeholder with
> the ajax response message
> $.post(url
>        ,{param: "value"}
>        ,function(r){
>          $('#status_div').html(r.message);
>        }
>        , "json");
>
> The complete code will be like this:
> $(trigger).click(function(){
>   $('#status_div').html(' Loading ...');
>   $.post(url
>          ,{param: "value"}
>          ,function(r){
>            $('#status_div').html(r.message);
>          }
>          , "json");
>
> });
>
> You can adjust this according to your need. This is what I like to do in
> my code (and my client so far happy with it) :)
>
> --
> Donny Kurniahttp://hantulab.blogspot.comhttp://www.plurk.com/user/donnykurnia


[jQuery] Re: get Ajax answer to test it

2009-04-16 Thread James

success: function(responseText){
 if (responseText == '1')  // do something
},


On Apr 16, 5:32 am, gostbuster  wrote:
> Hi everyone,
>
> I'm getting in trouble with ajax and jquery.
>
> Here is what i need:
>
> I want to execute a php script to test the value of an input. There is
> no problem with event and triggering the request. Here is my code :
>
> $.ajax({
>                          url: 
> 'emplacements/verifiernumero/numero/'+input.val(),
>                          success: function(responseText){
>                          // on success callback
>                                  alert("on a fait la 
> rek"+$.html(responseText));
>                          },
>
>                          error: function(responseText){
>                          // on error callback
>
> })
>
> the url is read thanks to zend_framework, which will take the
> parameter input.val
>
> the php script is rendering me something like :
> -if it'okay i get 1,
> else if get nothin
>
> If I executed the page 'emplacements/verifiernumero/numero/'+My_value
> I get 1 or nothingdepending of my tests..
>
> well what I want to do is get the "answer" of the script, to test it
>
> how can we do this ? I read the documentation, but didn't found.
>
> Thankyou in advance for your help .


[jQuery] Re: bassistance autocomplete and two fields

2009-04-16 Thread Khaoz

On 16 abr, 14:49, MorningZ  wrote:
> Since "inform id" or "inform the name" doesn't make much sense, do you
> mean
>
> "search for ID and fill in the name or search the name and fill in
> ID?"

Yes, that's it. Sry for my bad english.

> this would pretty much be done on the server side where you
> concatenate the two fields, search for the match, and then return the
> key/value pair and use "formatItem" to put them in their respective
> places

But if i want the id 1 the list will return:

1
10
11
12
13
...

Thats why i'm using a input for id and other for the name.

> On Apr 16, 1:12 pm, Giuliani Sanches 
> wrote:
>
> > I'm trying to use the autocomplete from 
> > herehttp://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
>
> > I have two fields in my database table:
>
> > id
> > name
>
> > In my form i need to be able to inform id and return the name or
> > inform the name and return id.
>
> > Is there some example around ?
>
> > Ty :)


[jQuery] Re: columnFilters

2009-04-16 Thread ManKuZo

Itès simplier to use the filterable plugins :  
http://plugins.jquery.com/project/filterable

On Apr 16, 9:33 am, ManKuZo  wrote:
> Hello,
>
>    I download the columnFilters plugins and test it, every thing is
> working fine. But, I want to filter my table on one specific column,
> so the added filter row above the table header is not relevant for me.
> I'm trying to modify the jquery.columnfilters.js that it will work
> with text file that I put outsite the table on the top. The code look
> like this. But, it's not working.
>
> $("#filter_field").keyup(function(event){
>
>     //  call the runFilters(event);
>    alert(" filter_field !");
>  });
>
> Can somebody help with this.
>
> Tks


[jQuery] Re: CTRL+S to Insert Record PHP+JQUERY

2009-04-16 Thread Hector Virgen
Actually, I just tried this and it works in Firefox 3 and IE8 beta.
jQuery(function($)
{
var pressed = {};
 $(document).keydown(function(event)
{
// Capture the key being pressed
var keyCode = event.keyCode;
pressed[keyCode] = true;
 // Check if 'S' was pressed
if (83 == keyCode) {
// Check if Ctrl + S (Windows) or Command + S (Mac) was pressed
if (pressed[17] || pressed[224]) {
alert('Custom save dialog!');
event.preventDefault(); // prevent the default save dialog
}
}
});
 $(document).keyup(function(event)
{
delete pressed[event.keyCode];
});
});
-Hector


On Thu, Apr 16, 2009 at 10:54 AM, Hector Virgen  wrote:

> You might be able to capture key combos by observing the document for
> keydown and keyup events, and storing the key's down/up state in a variable.
> Then, when the 's' key is pressed, check if 'ctrl' is also pressed.
> But like Ricardo said, CTRL+S may not be capturable since it's a browser
> shortcut.
> -Hector
>
>
>
> On Thu, Apr 16, 2009 at 9:18 AM, Ricardo  wrote:
>
>>
>> As far as I know you can't capture key combinations in Javascript, and
>> even if you could, CTRL+S is a browser shortcut, so it would probably
>> be overriden.
>>
>> On Apr 16, 2:24 am, bharani kumar 
>> wrote:
>> > Hi All ,
>> > Can u please tell ,
>> >
>> > How to implement  in jquery, php,,
>> >
>> > Insert record after pressed the CTRL+S in keyboard ,
>> >
>> > Thanks
>> >
>> > --
>> > உங்கள் நண்பன்
>> > பரணி  குமார்
>> >
>> > Regards
>> > B.S.Bharanikumar
>> >
>> > POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/
>>
>
>


[jQuery] Re: CTRL+S to Insert Record PHP+JQUERY

2009-04-16 Thread Nic Hubbard

http://jshotkeys.googlepages.com/test-static-01.html

On Apr 15, 10:24 pm, bharani kumar 
wrote:
> Hi All ,
> Can u please tell ,
>
> How to implement  in jquery, php,,
>
> Insert record after pressed the CTRL+S in keyboard ,
>
> Thanks
>
> --
> உங்கள் நண்பன்
> பரணி  குமார்
>
> Regards
> B.S.Bharanikumar
>
> POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/


[jQuery] Re: CTRL+S to Insert Record PHP+JQUERY

2009-04-16 Thread Hector Virgen
You might be able to capture key combos by observing the document for
keydown and keyup events, and storing the key's down/up state in a variable.
Then, when the 's' key is pressed, check if 'ctrl' is also pressed.
But like Ricardo said, CTRL+S may not be capturable since it's a browser
shortcut.
-Hector


On Thu, Apr 16, 2009 at 9:18 AM, Ricardo  wrote:

>
> As far as I know you can't capture key combinations in Javascript, and
> even if you could, CTRL+S is a browser shortcut, so it would probably
> be overriden.
>
> On Apr 16, 2:24 am, bharani kumar 
> wrote:
> > Hi All ,
> > Can u please tell ,
> >
> > How to implement  in jquery, php,,
> >
> > Insert record after pressed the CTRL+S in keyboard ,
> >
> > Thanks
> >
> > --
> > உங்கள் நண்பன்
> > பரணி  குமார்
> >
> > Regards
> > B.S.Bharanikumar
> >
> > POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/
>


[jQuery] clueTip plugin - onClose option in the API?

2009-04-16 Thread tatlar

Hi there,

I am using Karl's clueTip plugin in a table. When the user clicks a
link in the table, the clueTip pops up, and the CSS of the table cell
changes using the addClass method (adds a class called
'selectedCell'). This is all well and groovy, but what I want to do in
addition, is that when the user closes the clueTip window, the CSS of
the selected table cell reverts to its previous class. I was looking
for an onClose in the clueTip API options list and could not find
one.

Does anyone know how I could achieve this desired behavior? What I
have right now is that when the user clicks one cell all the current
table cells are reset (have the class removed) and then a class is
applied ('selectedCell'). When another a link is clicked in the table,
all the current table cells with that class have it removed, and the
newly clicked cell has the class applied:

$("a.jTip").click( function() {
$('table tbody tr td').removeClass('selectedCell');
$(this).parent().addClass('selectedCell');
}

clueTip is called thus:

$("a.jTip").cluetip({
cluetipClass: 'jtip',
arrows: true,
hoverIntent: false,
mouseOutClose: true,
sticky: true,
activation: 'click',
splitTitle: '|',
closeText: 'X',
closePosition: 'title',
tracking: true,
showTitle: true
}) ;

I want to add another option (in pseudo-code):
onClose: function(e) {
e.parent().removeClass('selectedCell')
}

Is this worth modifying the plugin for? Am I even going about this the
right way? Thanks in advance.


[jQuery] Re: recommendation for lightbox

2009-04-16 Thread chris at zeus

It's not a plug-in, but I would suggest FancyZoom.
http://www.cabel.name/2008/02/fancyzoom-10.html

On Apr 16, 9:20 am, iceangel89  wrote:
> what do u recommend for a lightbox plugin? there are alot out there


[jQuery] Re: bassistance autocomplete and two fields

2009-04-16 Thread MorningZ

Since "inform id" or "inform the name" doesn't make much sense, do you
mean

"search for ID and fill in the name or search the name and fill in
ID?"

this would pretty much be done on the server side where you
concatenate the two fields, search for the match, and then return the
key/value pair and use "formatItem" to put them in their respective
places


On Apr 16, 1:12 pm, Giuliani Sanches 
wrote:
> I'm trying to use the autocomplete from 
> herehttp://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
>
> I have two fields in my database table:
>
> id
> name
>
> In my form i need to be able to inform id and return the name or
> inform the name and return id.
>
> Is there some example around ?
>
> Ty :)


[jQuery] Setting a newly inserted option as the selected option

2009-04-16 Thread Nando

I'd like set a newly inserted option in a select box as the selected
option. I'm trying to use jQuery to select the option using the option
text, which begins with the author name as defined in the function.

In the examples I've found, $("#refSelectBox option[text^=author]")
would presumably select any option that begins with the literal
"author", but I need it evaluated instead.

Given the following ...

$("#addRefForm").submit(function() {
var author = $("#author").val()
var detail = $("#detail").val()
var refYear = $("#refYear").val()
var refType = $("#refType option:selected").val()
var newReference = 1
$.post('index.cfm?view=saveReferenceFromPopup', {
author:author,
detail:detail,
refYear:refYear,
refType:refType,
newReference:newReference
},  function(data,status) {
if(status == 'success'){
 
$("#refSelectBox").trigger('refreshOpts');
 $("#refSelectBox 
option[text^=author]").attr
("selected","selected");
  }
  }
);

$('#dialog').dialog('close');
return false;
});

... how to select the newly inserted option in #refSelectBox using the
text attribute and set it to the selected option?

Any alternate suggestions are most welcome!

Thanks,
Nando


[jQuery] Re: Creating an ajax status

2009-04-16 Thread Donny Kurnia

Nic Hubbard wrote:
> I have a number of GET and POST ajax calls that do various things my
> script.  For each one, I would like to set a status that is a string,
> so that I can out put that to the user.  So, it might look like this:
> 
> Ajax POST
> Posting to page
> 
> Ajax GET
> Getting content page
> 
> Ajax POST
> Sending data to page
> 
> Basically I want to set the status using something like $
> ('#status_div').text(); so that the user will see the status text when
> each ajax function is run.
> 
> Does anyone have ideas on how this could be accomplished?
> 

This is what I used to do:

1. In the click function handler, put the loading text and image to the
status placeholder.
$('#status_div').html(' Loading ...');

2. Call the ajax

3. In the ajax callbak function, I update the status placeholder with
the ajax response message
$.post(url
   ,{param: "value"}
   ,function(r){
 $('#status_div').html(r.message);
   }
   , "json");

The complete code will be like this:
$(trigger).click(function(){
  $('#status_div').html(' Loading ...');
  $.post(url
 ,{param: "value"}
 ,function(r){
   $('#status_div').html(r.message);
 }
 , "json");
});

You can adjust this according to your need. This is what I like to do in
my code (and my client so far happy with it) :)

--
Donny Kurnia
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia



[jQuery] bassistance autocomplete and two fields

2009-04-16 Thread Giuliani Sanches

I'm trying to use the autocomplete from here
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

I have two fields in my database table:

id
name

In my form i need to be able to inform id and return the name or
inform the name and return id.

Is there some example around ?

Ty :)


[jQuery] Jörn Zaefferer's documentation generator - documentation?

2009-04-16 Thread livefree75

Hi there,

Well I finally got Jörn's tool to work: 
http://jquery.bassistance.de/docTool/docTool.html

But I'm wondering if there's a list of supported tags.

I found out the hard way that you need to include a "@name" tag, even
if the docblock is right before the code.

Jamie


[jQuery] Re: Creating an ajax status

2009-04-16 Thread Jordon Bedwell

$.ajax supports an option called beforeSend so it would be something like:

$.ajax({
type:"POST",
url:"some.php",
data:"name=John&location=Boston",
success:function(msg){
alert("Data Saved: "+msg);
}
beforeSend:function() {
alert("Sending request to server');
}
 });

I am assuming you are using $.ajax because you are probably using the "same"
page with either GET or POST.

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Nic Hubbard
Sent: Thursday, April 16, 2009 11:31 AM
To: jQuery (English)
Subject: [jQuery] Creating an ajax status


I have a number of GET and POST ajax calls that do various things my
script.  For each one, I would like to set a status that is a string,
so that I can out put that to the user.  So, it might look like this:

Ajax POST
Posting to page

Ajax GET
Getting content page

Ajax POST
Sending data to page

Basically I want to set the status using something like $
('#status_div').text(); so that the user will see the status text when
each ajax function is run.

Does anyone have ideas on how this could be accomplished?



[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Ricardo

Josh,

I have to agree with Rob on the class thing. It's really not meant
specifically for presentation, it just happens to be one of the most
practical (and fully supported) selectors in CSS. There's no problem
in using jquery.metadata to store data in it, it's valid HTML (yes,
quirks mode can cause trouble, specially as your page gets more
complex. valid mark-up is a safety measure) and offers good enough
performance. Although I also agree with Rob that, if you already have
your data in an object coming through Ajax, there's no need to parse
it and throw it in the DOM just to recover it later. A simple
reference to the element would be enough, and you can identify it with
the ID attribute, sharing the object's unique id (if there is one).

cheers,
- ricardo

On Apr 16, 6:53 am, Josh Powell  wrote:
> @all - So far, the only reasons I've heard not to add custom
> attributes are 1) Dogma, 2) May cause quirks mode.  In my mind, the
> benefits gained by using custom attributes: less code, simplicity, and
> clarity, far outweigh these two reasons not to do it.
>
> @Jack K - Thanks for the links :).   I will consider adding 'data-' to
> future custom attributes.  But, I actually don't really care if my
> html code is a "valid" document.  Being a valid document has no
> practical meaning, all browsers render it just fine regardless of if
> it is "valid" or not.
>
> @RobG -
> I was being careless with my use of the words 'attribute' and
> 'properties', but did you really need to correct me 4 times, and then
> correct my use of override to overload twice?  I guess you did.
>
> The class attribute might not have the words 'presentation' and
> 'style' in the W3C definition, but if you tell me that the class
> attribute is not meant primarily for styling DOM elements, I'm just
> going to ignore everything else you say as you are just being
> argumentative.
>
> > So you've already got the data in an object, now you added it as
> > custom HTML attributes, then suck it back out again using attr().  Can
> > you see the silliness inherent in the system?
>
> Actually, I think it is less silly then appending an id onto the end
> of the attribute id and then parsing it to obtain the id of the object
> I'm looking for, and then creating a custom object with get/set
> methods to retrieve the appropriate object to get its properties.
>
> > Why not make the media object a bit smarter than just an array, say with 
> > set and get methods?
>
> Because that is unnecessary code.  It's code I do not need to write if
> I just add custom attributes.
>
> @Kean 
> -http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-cor...
> To sum up:
>   - string concatenation is plenty fast 99% of the time and a lot more
> readable.
>   - W3C DOM Node creation is much slower then inserting via innerHTML,
> especially as you add more nodes.  It doesn't matter how fast the
> nodes are created, it will always be slower to create, adjust, and
> insert 10,000 nodes then one string.


[jQuery] Creating an ajax status

2009-04-16 Thread Nic Hubbard

I have a number of GET and POST ajax calls that do various things my
script.  For each one, I would like to set a status that is a string,
so that I can out put that to the user.  So, it might look like this:

Ajax POST
Posting to page

Ajax GET
Getting content page

Ajax POST
Sending data to page

Basically I want to set the status using something like $
('#status_div').text(); so that the user will see the status text when
each ajax function is run.

Does anyone have ideas on how this could be accomplished?


[jQuery] Re: How to pick out classes that start with a particular string.

2009-04-16 Thread Ricardo

Short answer:

$(".button").each(function(){
var icon = /icon(\w+)/.exec(this.className)[1].toLowerCase();
   $(this).append('');
});

- ricardo

On Apr 16, 9:58 am, jonhobbs  wrote:
> This might be hard to explain, but I need a way to loop through a
> bunch of elements I've already selected and for each one find classes
> that start with the word "icon". So for example I might have the
> following elements
>
> 
> 
> 
> 
> 
> 
>
> So, I begin by selecting the elements and looping through them
>
> $(".button").each(function(){
>     // Some code here
>
> });
>
> Now, I could put the following code in the loop...
>
> if ($(this).hasClass("iconStar")){
>     $(this).append("");
>
> }
>
> I would then have to repeat that for each possible icon, which seems
> very inefficient.
>
> What I'd like to do in the "each" loop is just cycle through all the
> classes that $(this) has and pick out the one that begins with ICON
> and then use that to append the image.
>
> Can anyone help?


[jQuery] Re: CTRL+S to Insert Record PHP+JQUERY

2009-04-16 Thread Ricardo

As far as I know you can't capture key combinations in Javascript, and
even if you could, CTRL+S is a browser shortcut, so it would probably
be overriden.

On Apr 16, 2:24 am, bharani kumar 
wrote:
> Hi All ,
> Can u please tell ,
>
> How to implement  in jquery, php,,
>
> Insert record after pressed the CTRL+S in keyboard ,
>
> Thanks
>
> --
> உங்கள் நண்பன்
> பரணி  குமார்
>
> Regards
> B.S.Bharanikumar
>
> POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/


[jQuery] Re: hover problems

2009-04-16 Thread Jack Killpatrick

the technique here might be of interest:

http://www.ihwy.com/Labs/demos/Current/image-hover-menu.aspx

- Jack

Rick Faircloth wrote:

Check out the "Hover Intent" plugin here:
 
http://cherne.net/brian/resources/jquery.hoverIntent.html
 
I think it's just what you're looking for.
 
Rick


On Thu, Apr 16, 2009 at 12:28 AM, 3daysaside <3daysas...@gmail.com 
> wrote:



Been searching for the last hour, found some solutions, but still not
good enough.

I have a navigation menu -- when I hover over a header, I want the
submenus to slideDown, and then on hoverOut, I want it to slide back
in.  First, I was having problems with it only displaying 2 or 3 of
the dropdown items if I got crazy with the hovering (on, off, on, off
quite rapidly).  Then I found the .css(overflow:visible) fix.  That
causes the menu to at least always display all the items, but the
effect is lost if you hover on/off quickly.

What am I missing?  This can't be this hard.

Here's the link:

http://www.threedaysaside.com/cep

Javascript:
$(document).ready(function() {
   $(".sub_div").hide();
   /*$(".sub_div").css('opacity', 0.9);*/
   $(".subnav_a").hover(function() {
   $(".sub_div").stop().css('overflow',
'visible').slideDown(800);
   }, function() {
   $(".sub_div").stop().css('overflow',
'visible').slideUp(300);
   });
});

The Residential link is the only one with a dropdown.  And don't worry
about the styling, I haven't even had a chance to worry about it
myself yet.




--
-
"It has been my experience that most bad government is the result of 
too much government." - Thomas Jefferson




[jQuery] Re: Menu Hover and Selected

2009-04-16 Thread Takaya213


I'm afraid you will have to eat your shoe, it doesn't work. :-((

http://www.njwebdesign.co.za/


victorg84 wrote:
> 
> 
> Small correction..
> 
> var activePage = window.location.pathname.substr(1);
> $("a[href="+activePage+"] img").trigger("mouseover");
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Menu-Hover-and-Selected-tp22999583s27240p23081451.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] .navButtonAdd Quick Question...

2009-04-16 Thread briandus

Hi there - I'm adding a custom button using the .navButtonAdd
function. I see that there is an option for an image, but I'm
wondering if I can create a button and apply a class instead. I have a
"toggle" button that I'm adding and the image will change with the
toggle state. Is this possible?

Thanks!


  1   2   >