Re: [jQuery] Re: Sortable list - even when list is changed

2010-02-23 Thread Peter Edwards

In your example, you have two calls to $('#elements').sortable().
The second one has the update event added, but the first (the one which 
creates the sortable) doesn't. If you add the update handler to the 
first call, it works OK.


on 23/02/2010 08:26 rafald said::

Hi ,
please check this:
http://jsbin.com/oququ3/6/edit

As you can see:
- sortable list works
- accordion works
...but:
- POPUP 'update'  does not come

what could be wrong here?
regards
Rafal



Re: [jQuery] Re: Sortable list - even when list is changed

2010-02-23 Thread Peter Edwards

No problem,

$(document).ready(function(){
});

and

$(function(){
});

are the same - both will run whatever you have in them when the DOM is 
ready - the second is just a kind of shorthand for the (much easier to 
read) first. Docs:


.ready()
http://api.jquery.com/ready/

$(callback)
http://api.jquery.com/jQuery/#jQuery3

When you have multiple instances of these constructs in your scripts, 
the code within them will run in the order in which they are defined, so 
in your example, what was happening was the first 
$(#elements).sortable(); (defined within the $(function(){}); block) 
was creating the sortable list - the second call (within 
$(document).ready) was ignored.


Hope this helps,

Peter


on 23/02/2010 10:32 rafald said::

Hi Peter,
Indeed! It works ;-) THANKS!
It was enough to remove line with  $(#elements).sortable(); 

So, what is the right place to put:
$(#elements).sortable();
?

in my example:
the first place was outside $(document).ready(function()
the second place (where I added event) was inside $
(document).ready(function()

What are the rules  here and what will be difference if I put inside
or outside ?
Could you please explain this to me ?

regards
Rafal



Re: [jQuery] How to select every checkbox on my page inside a fieldset

2010-02-15 Thread Peter Edwards

You can use selectors to do this quite easily - I've posted an example at:

http://jsbin.com/uwaxo/

This has:
1. a checkbox which will select/deselect all others in the page (no 
matter whether they are in different forms/fieldsets,
2. a checkbox which uses a descendant selector $('#fieldset1 
input:checkbox') to explicitly target a given fieldset by ID, and
3. a checkbox which uses its place in the DOM to select checkboxes which 
are within the same fieldset it is part of.


I hope one of these addresses your problem

on 15/02/2010 13:16 ReynierPM said::

Hi:
I have a fieldset and a set of check boxes inside. I want when I pick 
one, for example: input type='checkbox' id='pick_all' 
value='picked_all' / Pick all check boxes all the check boxes will be 
checked. How?


Re: [jQuery] google.load(jquery) and jquery plugins

2010-01-27 Thread Peter Edwards
Use google.setOnLoadCallback to add whatever plugins you need using 
jQuery's $.getScript function like this:


google.load(jquery, 1);
google.setOnLoadCallback(function() {

$.getScript(http://inlinemultiselect.googlecode.com/files/jquery.inlinemultiselect-1.2.min.js;, 
function(){

$('select.normal').inlinemultiselect();
  });
});




on 26/01/2010 19:04 barton said::

When I try to use google.load to load jquery I have problems loading
other jquery plugins. Somehow I need to be able to wait for jquery to
be loaded by the google Ajax api before doing the script type=text/
javascript src=thePluginThatNeedsJquery/script
I know that google has google.setOnLoadCallback(function() {
but how do I do the script stuff inside that?

The answer must be pretty obvious as I couldn't find anything when I
searched the group but I don't see it.

Thanks



Re: [jQuery] iPhone: split jquery script file

2010-01-14 Thread Peter Edwards
There is an interesting article about optimising YUI for Safari/iPhone at:

http://tinyurl.com/y97karc
(there was a problem with the blog's database connection, so this links to a
cached version)

With the following in it:

Some examples of the kinds of things an iPhone-specific site doesn’t need:

* Keyboard navigation and shortcuts: The iPhone doesn’t have arrow keys
 and the keyboard only appears when a text input element has focus, so code
 that handles keyboard shortcuts and navigation events is unnecessary.
* Hover states and mouse movement handlers: Since the iPhone is a
 touchscreen device, there’s no mouse cursor and thus no way for the user to
 hover over an element. Mobile Safari fires the mousemove and mouseover
 events just before the mousedown, mouseup, and click events, and it fires
 the mouseout event when an element loses focus.
* Context menus: There’s no way to right-click or control-click on the
 iPhone, so the contextmenu event cannot be triggered.
* Text selection and clipboard handlers: Sadly, the iPhone does not
 provide clipboard functionality or a way to select text in an input element,
 so these handlers are useless.


I guess you could edit all these parts out of the uncompressed jQuery
source, and then compress it all down to less than 25Kb - has anyone done
this?


On Thu, Jan 14, 2010 at 9:30 AM, m-schmidt micha_schm...@me.com wrote:
 Hi,

 the iPhone has a cache limit of 25KB, so the jquery script file will
 never be cached. Is it possible to split the jquery file in 5-10
 smaller files for the iPhone?

 thanks,
 Micha



Re: [jQuery] Re: iPhone: split jquery script file

2010-01-14 Thread Peter Edwards
The cache limit is for individual files, so you get jquery down under 25K,
then use CSS sprites (with images less than 25K) for backgrounds - the total
cache size is 475K (a maximum of 19 components can be cached). Gzipping
doesn't count (the limit applies to uncompressed code) but minifying is a
must I guess.

On Thu, Jan 14, 2010 at 3:13 PM, MorningZ morni...@gmail.com wrote:

 but what would be the point?

 say you got jQuery down to 10k in size  that leaves 15k left for
 images and HTML and etc, it's just going to hit that limit and purge
 the cache anyways.  but just a few requests sooner

 keep with the minified and gzipped version to keep the data sent
 across the connection to a minimum...ripping apart the library
 just doesn't seem worth the payoff, which isn't much anyways

 On Jan 14, 10:08 am, Peter Edwards p...@bjorsq.net wrote:
  There is an interesting article about optimising YUI for Safari/iPhone
 at:
 
  http://tinyurl.com/y97karc
  (there was a problem with the blog's database connection, so this links
 to a
  cached version)
 
  With the following in it:
 
  Some examples of the kinds of things an iPhone-specific site doesn’t
 need:
 
 
 
  * Keyboard navigation and shortcuts: The iPhone doesn’t have arrow
 keys
   and the keyboard only appears when a text input element has focus, so
 code
   that handles keyboard shortcuts and navigation events is unnecessary.
  * Hover states and mouse movement handlers: Since the iPhone is a
   touchscreen device, there’s no mouse cursor and thus no way for the
 user to
   hover over an element. Mobile Safari fires the mousemove and mouseover
   events just before the mousedown, mouseup, and click events, and it
 fires
   the mouseout event when an element loses focus.
  * Context menus: There’s no way to right-click or control-click on
 the
   iPhone, so the contextmenu event cannot be triggered.
  * Text selection and clipboard handlers: Sadly, the iPhone does not
   provide clipboard functionality or a way to select text in an input
 element,
   so these handlers are useless.
 
  I guess you could edit all these parts out of the uncompressed jQuery
  source, and then compress it all down to less than 25Kb - has anyone done
  this?
 
  On Thu, Jan 14, 2010 at 9:30 AM, m-schmidt micha_schm...@me.com wrote:
   Hi,
 
   the iPhone has a cache limit of 25KB, so the jquery script file will
   never be cached. Is it possible to split the jquery file in 5-10
   smaller files for the iPhone?
 
   thanks,
   Micha



Re: [jQuery] any help on this!!!

2010-01-12 Thread Peter Edwards
You need a hash symbol for your button selector, and change the toggle 
to click:


$(#dt-link1).click(function() {
  $('#jqdt').find('ol li:eq(0)').css(color,Blue);
  return false;
});

on 11/01/2010 22:45 JQueryNewbie said::

I cant get my color  change on my listitem. any help would be
appreciated. Thanks in advance.

head
title/title

script src=scripts/jquery-1.3.2.js type=text/javascript/
script
script type=text/javascript
$(document).ready(function() {
$(dt-link1).toggle(function() {
$('#jqdt').find('ol li:eq(0)').css(color,Blue);
   return false;
});
});
/script

/head
body

div id=jqdt
ol
lilist item 1 with dummy link to silly.pdf /li
lilist item 2 with class=goofy /li
lilist item 3 SURPRISE! /li
lilist item 4 with silly link to silly.pdf /li
/ol
/div

br/
   button id=dt-link1 type=buttontoggle first list item/button
   button id=dt-link2 type=buttontoggle first li even/button

/body



Re: [jQuery] Custom animations

2010-01-10 Thread Peter Edwards

Hi there,

I've put up a basic example of how you would do this at:

http://jsbin.com/ahevu
(to edit the code, go to http://jsbin.com/ahevu/edit)

I've used mouseenter to demonstrate - if you need a hover effect, then 
you will need to save the original dimensions/position of the div you 
are animating so it can revert to them when the mouseleave event fires.



on 09/01/2010 19:22 Wroathe said::

Hi there! I was curious if there is a way to set up custom animations
so that a div will expand from a specified corner to another specified
corner?

(Ex. If I have a div with a background color of #000 that is 200px by
200px and when I hover over it it expands to 500px by 500px from top
left to bottom right, by default. I want it to expand from top right
to bottom left or bottom right to top left, etc.)

This is how I have it set up (but it only goes from top left to bottom
right)

$('div.item').hover(function() {
$(this).animate(
height: 500px,
width: 500px
);
});



Re: [jQuery] Generating a CSV of values from a bunch of Checkboxes with same id

2010-01-09 Thread Peter Edwards
You could use the title attribute rather than your non-standard txt 
attribute, and achieve the same thing using:


script type=text/javascript
$(document).ready(function(){
$(#tryme).click( function(){
var checkedGenres = [];
$(input[rel='genre']:checked).each(function(){
checkedGenres.push($(this).getAttribute('title'));
});
alert( checkedGenres.join(, ) );
$(#divGenres).text(checkedGenres.join(, ));
});
});
/script



on 09/01/2010 13:57 swfobject_fan said::

Hi,

I'm using this piece of code to find a set of selected check boxes
that are selected abd build a comma separated list from their values
('txt' custom attribute). Is this a jQuery standard method?

e.g
input type=checkbox id=chkGenre rel=genre value=12
txt=Rock / br /
input type=checkbox id=chkGenre rel=genre value=13 txt=Jazz /

script type=text/javascript
$(document).ready(function(){

$(#tryme).click( function(){
var oChecked = $(input[rel='genre']:checked);
var checkedGenres = new Array;
for( var i=0; ioChecked.length; i++ ) {
checkedGenres[i] = oChecked[i].getAttribute('txt');
}

alert( checkedGenres.join(, ) );
$(#divGenres).text(checkedGenres.join(, ));
});

});
/script



Re: [jQuery] Re: Debuging AJAX

2009-11-25 Thread Peter Edwards

Hey,

don't use document.write() or alert() to debug - either use 
console.log() or have a div in the document which can display debugging 
information and append any data to it.


$('#testform').live('submit',function(){
   var formData = $(this).serialize();
   console.log(formData);
   $.post('ajax/setvalue.php', formData, function(data){ console.log(data) });
});

Firebug should log the POST as well as any response from it as well.

HTH

on 25/11/2009 21:10 Rockinelle said::

Any new eyes out there? Not sure why this got changed to accessibility
discussion.

On Nov 24, 4:46 pm, Rockinelle ericbles...@gmail.com wrote:
  

Hey everyone,

I've been trying to make a .post work for me and I'm using firebug to
attempt to debug my problems. I am trying to use ajax to process a
form and from what I can tell in Firebug, I am not getting a response.
Now I have removed the action in the form itself so it's just reloads
the page after the .post fails.

$('#testform').live('submit',function(){
var formData = $(this).serialize();
alert(formData); //to verify the data is formatted properly and it
is.
$.post('ajax/setvalue.php', formData, function(data)
{ document.write(data) });

});

The path to the remote script is correct. formData is formatted
properly. The php doc only echo the string 'pass' to let me know it
got the request. I'm using .live rather than .submit because the form
is loaded via an ajax call so it waits for the form to load before it
binds this ajax request to the form.

So if you have some tips on my code great, but I'd really like a good
tool to debug this myself. Maybe there is something in firebug I'm
missing.



  


[jQuery] Re: Ajax - Access data arguments in callback

2009-09-18 Thread Peter Edwards


Hi there,

The only way I could find to do this with the $.get function was to 
parse out the query string - the success callback should get a copy of 
the options object which was used to set up the ajax request, but the 
data parameter is NULL in this object for GET requests (it is populated 
by the data parameters in POST requests however).


For example (using your example with a few changes):

$(function(){
 $('input:checkbox').click( function() {
   $.get('/ajax.php',{'nr': $(this).attr(id) }, function( data, 
textStatus ) {
 // this contains the options object used in the ajax request - 
this.data is null in GET requests

 // parse out the query string used for the request
 var qs = this.url.substr((this.url.indexOf(?)+1));
 var nvp = qs.split();
 // make an object which will hold the key/value pairs
 var params = {};
 for (var i = 0; i  nvp.length; i++) {
   var p = nvp[i].split(=);
   params[p[0]] = p[1];
 }
 $('#'+params.nr).attr(checked, checked);
   });
   return false;
 });
});








on 18/09/2009 08:53 Flamer said::

Thanks for your reply.

Does this not gives problems when I have an AJAX request with a
timeout after say 2 seconds, but in the meantime there's another
request using the same variable? Or is the sentData only accessible in
the click( function(){ } ) scope?

There is no other way of getting the data I sent with the request?

On 17 sep, 15:28, Nick Fitzsimons n...@nickfitz.co.uk wrote:
  

2009/9/17 Flamer mkapp...@gmail.com:







Hello,
  
Is it possible to access the data arguments that are sent with the

ajax function?
  
Example:

$('#mycheckbox').click( function() {
   $.get( '/ajax.php', { nr: this.id }, function( data, textStatus ) {
   // Here I want to access the arguments I just sent with ajax.php
  
   // As example, something like this:

   $('#'+arguments.nr).attr('checked', 'checked');
   } );
  
   return false;

} );
  

If I understand you correctly, then assigning your data object to a
variable which can be accessed via a closure in the callback function
would do it - something like:

$('#mycheckbox').click( function() {
   var sentData = { nr: this.id };
   $.get( '/ajax.php', sentData, function( data, textStatus ) {
   // Here I want to access the arguments I just sent with ajax.php

   // As example, something like this:
   $('#'+ sentData.nr).attr('checked', 'checked');
   } );

   return false;

} );

should be all you need.

Regards,

Nick.
--
Nick Fitzsimonshttp://www.nickfitz.co.uk/



  


[jQuery] Re: Paste an image into a tag...

2009-09-18 Thread Peter Edwards

Have you thought of using a rich text editor to do this such as
TinyMCE and FCKEditor - they both have paste from clipboard
functionality

On Fri, Sep 18, 2009 at 11:12 AM, Hogsmill i...@hogsmill.com wrote:

 This may or may not be possible, but if anyone knows a way to do it,
 I'd love to hear from you.

 Basically, I simply (?) want to copy an image (e.g. from ALT-Print
 Screen or 'Copy Image'), and paste/drop it into an img tag on a page
 so it appears on the page. I can then resize, drag-drop, etc. as
 required.

 I've had a rummage around the net, but can't find anything. Maybe it's
 impossible?

 Cheers,

 Steve



[jQuery] Re: Using jQuery to see if CSS is disabled.

2009-09-05 Thread Peter Edwards


You could try looping through the document.styleSheets collection and 
testing the disabled attribute:


var styleSheetsDisabled = false;
for (var i = 0; i  document.styleSheets.length; i++) {
 if (document.styleSheets.item(i).disabled) {
   styleSheetsDisabled = true;
 }
}

Not sure if this would work as you expect - for more info, try 
http://dorward.me.uk/software/disablecss/



on 04/09/2009 00:50 mumbojumbo said::

Hello All,

I'm trying to code a site using progressive enhancement methods. It's
built upon standards-compliant CSS and HTML and JS. I'm using jQuery
on the site to animate some elements on hover etc. Now, when CSS and
JS is disabled, it's all good. But, If CSS is disabled and JS is still
enabled, the js still manipulates the elements and it's not what I
want. I was wondering if anybody knew anything about this. I can't
seem to find anything about this...

  


[jQuery] Re: search list in a div for attribute value

2009-08-29 Thread Peter Edwards


Try this - it may work for you:

$(function(){
 var srch = [ foo, bar ] ;
 // make a Regex from the search terms
 var attr_regex = '('+srch.join('|')+')';
 $('#gallery li').each(function(){
   if ($(this).attr(title).match(attr_regex)) {
 $(this).css({background:'#f00'});
   }
 });
});   



on 28/08/2009 21:31 tatlar said::

Oops. This sentence:
I want to traverse the array, looking at the title attribute, and if
it is in the array $search I want the style changed. 
Should be:
I want to traverse the list, looking at the title attribute, and if
it is in the array $search I want the style changed.

And this:

var $title_to_search = value;
// pseudo code I know this is junk
$gallery.find('li').attr('title',$title).css('background-
color','red');

Should be:
var $title_to_search = value;
// pseudo code I know this is junk
$gallery.find('li').attr('title',$title_to_search).css('background-
color','red');


On Aug 28, 1:27 pm, tatlar robertlnew...@gmail.com wrote:
  

i think this is a pretty simple question, but i can't seem to figure
it out.

i have a list in a div:

div id=gallery
ul
  li title=foofoo/li
  li title=barbar/li
  li title=unicornunicorn/li
/ul
/div

I have an array with values in it:

var $search = [ foo, bar ] ;

I want to traverse the array, looking at the title attribute, and if
it is in the array $search I want the style changed.
Note that #gallery has about 450 list items - the one above is
abridged for this post.
The array $search will at most have 5 items.

So, is it faster to do a $.each() on the list items, or do a $.each()
on the $search items. I am pretty sure it is faster to do the latter,
but I am not sure how to get the title attribute from the list items
for the match.

Something like?

$.each( $search, function(i, value) {
var $title_to_search = value;
// pseudo code I know this is junk
$gallery.find('li').attr('title',$title).css('background-
color','red');

});

Can someone refine this for me? Thanks in advance.



  


[jQuery] Re: Getting XML info problem

2009-08-25 Thread Peter Edwards


Your code suffers from asynchronousitis. You call the ajax request, but 
alert the total before the response can alter the variable. Try doing it 
in the success callback as the previous poster suggested and you will 
get the correct value:


 var total = 0;
 function readXML(section) {
  $.ajax({
 type: GET,
 url : xmldata/picslist.xml,
 dataType: xml,
 success: function(xml){
alert(xml.getElementsByTagName(pic).length); // alerts 4
total = xml.getElementsByTagName(pic).length; // sets total to 4
 }
  });
  alert(total); // alerts 0 - executed as soon as the ajax request is 
sent - before the response

 };


on 25/08/2009 10:51 ximo wallas said::

I find it really sad that jquery doesn't have a oficial forum out there...
My question is posted in this one, I can't post it here cause the HTML 
inside will blow the e-mail:

http://www.jqueryhelp.com/viewtopic.php?t=3616
Can somebody help me with this, I'm really stuck...




[jQuery] Re: form elements brainteaser

2009-08-19 Thread Peter Edwards


Hi Chris,

I have a working example at:

http://jsbin.com/udota/

I've made the number of second inputs configurable so you can test it.
All you need now is a way of checking if they all add up to 100 if you 
make them user configurable - I'll leave that up to you though!


Peter

on 19/08/2009 21:17 Chris Hall said::

I have a good idea of what I want to accomplish, but I'm not sure how
to do this with jquery.

If you can help give me an idea of what I must do or how to accomplish
this I would GREATLY appreciate it!

I have a form that can has 4 radio buttons and two sets of text
inputs.  The first set always contains 6 inputs.  the second set can
contain between 1 and 5 inputs.

The goal is to allow the user to enter numbers in the two groups of
inputs that total 100 (in both groups combined, not 100 for each
group).

If the first radio button is selected, I fill the first group (6 text
inputs) with 17, 17, 17, 17, 16, 16 (easy because the number of text
inputs in this group do not change), and place all 0's in the second
group of text inputs.

If the second radio button is selected, I must count the number of
text inputs in this group and divide 100 between this group and place
all 0's in the first group of text boxes (and the total must equal 100
so some boxes may have 1 more than others).

If the third radio button is selected, I must count all text inputs
(first and second group) and divide 100 between this group (and the
total must equal 100 so some boxes may have 1 more than others).

If the 4th radio button is selected I make all the text boxes enabled
(otherwise they have been disabled) and the user can enter a custom
configuration.

I've went at this several different ways, but none work well.

This brainteaser has me pulling out what little hair I have left.

If you can offer any help I would *GREATLY* appreciate it.

  


[jQuery] Re: Manipulate href

2009-08-17 Thread Peter Edwards


Hi knal

This works for me:

$(function(){
 $('#my_list a').each(function(){
   var href = $(this).attr(href);
   /* remove trailing slash if present */
   if (href[(href.length-1)]===/) {
 href = href.substr(0,(href.length-1));
   }
   /* now get the last part of the path */
   var anchorname = ;
   if (href.lastIndexOf(/)===-1) {
 /* no more slashes - return full path */
 anchorname = href;
   } else {
 /* get everything after the last slash */
 anchorname = href.substr((href.lastIndexOf(/)+1));
   }
   /* now set the href to the anchor */
   $(this).attr(href, #+anchorname);
 });
});

A regex would be more elegant if I had the time to write one and test 
it, but this should suffice for most situations.


Peter

on 17/08/2009 20:07 knal said::

Hi group,

I'm looking for a correct way of manipulating a hrefs...
The code looks like this:

ul id=my_list
  lia href=/portfolio/category/animals/Animals/a/li
  lia href=/portfolio/category/buildings/Buildings/a/li
  lia href=/portfolio/category/cars/Cars/a/li
  lia href=/portfolio/category/people/People/a/li
/ul

and with jQuery i want to manipulate it into this:

ul id=my_list
  lia href=#animalsAnimals/a/li
  lia href=#buildingsBuildings/a/li
  lia href=#carsCars/a/li
  lia href=#peoplePeople/a/li
/ul

So only the last element in the URL has to stay, and a hash has te be
added...
I wouldn't know how to achieve this. I've been googling it for three
hours now, but i jus't can't get it to work.
Any help would be greatly appreciated!

Thanks,
Knal

  


[jQuery] Re: Add extra content to the title attribute

2009-08-11 Thread Peter Edwards
try this:

$(a.newWindow).attr(title, $(a.newWindow).attr(title)+ - This link
will open in a new window);

On Tue, Aug 11, 2009 at 10:45 AM, Paul Collins pauldcoll...@gmail.comwrote:

 Hi all,
 This is hopefully simple. I have a bunch of links with titles, like
 TITLE=Facebook and so on. I am adding JQuery to make the links open in a
 new window and would like to add some text to the title that says this link
 will open in a new window, whilst keeping the original text. I'm using the
 add JQuery command, but this actually replaces the original title text.

 $(a.newWindow).attr(title,  - This link will open in a new window);

 The end result I would like to have is: title=Facebook - This link will
 open in a new window.

 Could anyone point me in the right direction?!
 Cheers




[jQuery] Re: jQuery toggle question

2009-08-06 Thread Peter Edwards


I've reworked your code a little with a working example at:

http://jsbin.com/ecumi

I have changed classes and ids in the document a little to make it 
easier to do the selectors, but I know it could probably be done more 
efficiently.


Peter

on 06/08/2009 01:13 ripcurlksm said::

For once, I have a script fully working... I have four tabs that pull down
when clicked. If a tab is open, and you click another tab, the opened tab
closes first, then the selected tab opens.

Here is a working example (Open Tab1, then click Tab2 and note how it closes
quickly, i want Tab1 to slide closed, then Tab2 slide open):
http://psylicyde.com/misc/slide-panel

The problem is that the open tab closes abruptly when changing tabs. Is
there anyway to smooth it out? Here is my code, with highlights.

===
Source Code
===

$(document).ready(function(){

$(.btn-slide1).click(function(){
// first close any other open panels
$(#panel2).hide();
$(#panel3).hide();
$(#panel4).hide();

// then open the selected panel
$(#panel1).slideToggle(slow);
$(this).toggleClass(active); return false;
});

$(.btn-slide2).click(function(){
// first close any other open panels
$(#panel1).hide();
$(#panel3).hide();
$(#panel4).hide();

// then open the selected panel
$(#panel1).hide();
$(#panel2).slideToggle(slow);
$(this).toggleClass(active); return false;
}); 

$(.btn-slide3).click(function(){
// first close any other open panels
$(#panel1).hide();
$(#panel2).hide();
$(#panel4).hide();

// then open the selected panel
$(#panel3).slideToggle(slow);
$(this).toggleClass(active); return false;
}); 

$(.btn-slide4).click(function(){
// first close any other open panels
$(#panel1).hide();
$(#panel2).hide();
$(#panel3).hide();

// then open the selected panel
$(#panel4).slideToggle(slow);
$(this).toggleClass(active); return false;
}); 
	 
});


  


[jQuery] Re: More fun with decrementing on click

2009-08-03 Thread Peter Edwards


Hi Nick

$(.number).html(count--);

count-- decrements your count variable after it has passed its value to 
the $.html() function.

use --count

Peter

on 03/08/2009 21:15 littlerobothead said::

I have a status area in an app I'm working on. It shows the number of
unread alerts. As the user clicks each alert, it's subtracted from the
total. The following code counts the number of items to use as my
total:

var trigger = $(#dataset-b tr.unread);
var count = $(trigger).length;
$(.number).html(count);

And then this works to subtract from that number on each click:

$(trigger).click(function(){
$(.number).html(count--);
if (count == 0){
$(trigger).unbind(click);
}
$(this).removeClass('unread');
});

Problem is, nothing happens on the first click. However, on the second
click my number starts to decrement. What's going on here? How can I
make the count work?

Best,
Nick

  


[jQuery] Re: Check if movie (.mp4) is finished

2009-07-26 Thread Peter Edwards


Hi Eswip,

It is possible to use the getEndTime method of the quicktime movie, but 
I think only when the plugin/movie has loaded. Apple docs:


http://developer.apple.com/documentation/QuickTime/REF/QT41_HTML/QT41WhatsNew-74.html

Not sure how you would implement this though...

bjorsq

on 25/07/2009 17:26 Eswip said::

Hi everyone,

I'm using the jQuery Media Plugin to play a movie (.mp4) on a page
when a button is clicked. But I want to remove the embed from the
DOM when the movie is finished. Is this possible? And in what way? I
searched on the group here and googled, but I found nothing.

Regards,
Eswip

  


[jQuery] Re: URL generated by Ajax

2009-07-15 Thread Peter Edwards


Hi JD,

In your success callback, you have access to ajax options through the 
this keyword, so you can get the full URL by doing this within the 
success callback:


alert(this.url+'?'+this.data);

peter

on 15/07/2009 13:30 Mean Mike said::

if you just need to see what your posting and what url its going too
why not just view it in httpfox ?

On Jul 15, 6:54 am, JD odonovan.jo...@gmail.com wrote:
  

Hi Guys,
This is probably a very simple question, i'm new to JQuery but I
can't find the solution.
I create an AjaxReqest with a url and some post data. Is there any way
that i can alert out the URL which is then generated in the call.

Example
   url:www.yahoo.com/login
   postdata: username=user password=pass
   Creates something along the lines 
ofwww.yahoo.com/login?username=userpassword=pass

Obviously the real calls are much more complex.

I have read somewhere that the argument to the onSuccess function
should expose a .url function but this doesn't seem to work.

Any help is appreciated.

Thanks

JD



  


[jQuery] Re: Determine content type in $.post callback

2009-07-13 Thread Peter Edwards


Hi Dimitriy,

To get the options used by the xhr request (including the ContentType 
header), use the this keyword in the callback function:

$.post(url, data, function(){
   /* the content of this from a typical $.post operation
   this[type]=POST
   this[url]=url
   this[data]=data
   this[success]=[callback function]
   this[dataType]=undefined
   this[global]=true
   this[timeout]=0
   this[contentType]=application/x-www-form-urlencoded
   this[processData]=true
   this[async]=true
   this[username]=null
   this[password]=null
   this[accepts]=[object]
   */
   var ContentTypeHeader = this.contentType;
})

on 13/07/2009 11:38 dnagir said::

Hi Rob,

But I don't see where I can get the XMLHttpRequest objects.
Only one thing related to XHR is this.xhr() function. And it returns a
new XHR object, so obviously it has no headers.

What am I missing?

Cheers,
Dmitriy.

  

How can I check the ContentType header in the $.post callback?
  

Try the W3C XMLHttpRequest Object specification:

URL:http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/#dfn-getresponse...



  


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

2009-07-13 Thread Peter Edwards


Hi Matt,

The if and else blocks are not both being executed.

try this:

$(function(){
 $('#billable_checkbox').change(function(event){
   if (this.checked) {
 $('#billable_hidden').attr(disabled, disabled);
   } else {
 $('#billable_hidden').removeAttr(disabled);
   }
 });
});

The most important change is using the disabled attribute on the field 
rather than the javascript property.
I've tried the above on a text input field to see if it worked (so I had 
a visual cue to whether the field was disabled or not) and it does.


Peter

on 13/07/2009 14:49 Matt Zagrabelny said::

On Fri, 2009-07-10 at 23:51 +0200, Massimo Lombardo wrote:
  

Please, using plain English only, explain what you want to do.
Then we'll try to help ;)



Alright.

  

The glitch is probably caused by the fact that the two input fields
*do* share the same name; then when you touch one, you *do* alter
both! Bug or feature?



Having two DOM elements with the same name attribute is still valid (see
input type=radio.)

My main question is how does both the 'if' block and the 'else' block get
executed in the same pass through the function?

  

As far as I got it, (and pretending that I got it right) you're trying
to enable/disable an hidden input field based on another checkbox's
checked state.



That is it.

That way only one of the two inputs of name=billable get sent to the
handler on the server.

This page is a RT (request tracker) module and RT handles the processing
of the (server-side.) I would rather not modify the RT codebase to
handle the checkbox - I thought it could be done via JS.

My main questions still stands, how does both the 'if' and 'else' blocks
get executed on the same pass through the function?

Thanks for the time and help.

Cheers,

  

On Fri, Jul 10, 2009 at 22:38, Matt Zagrabelnymzagr...@d.umn.edu wrote:


Greetings,

I am experiencing some crazy stuff, at least crazy to me...

Both the 'if' and 'else' blocks (according to firebug) are being
executed in the following anonymous function:

html
head
script language=javascript type=text/javascript
src=/usr/share/javascript/jquery/jquery.js/script
script language=javascript type=text/javascript
$(function() {
 add_billable_oncheck();
});

function add_billable_oncheck() {
 var billable_hidden   = $('#billable_hidden')[0];
 var billable_checkbox = $('#billable_checkbox')[0];
 if ((billable_hidden   != null) 
 (billable_checkbox != null)) {
   $(billable_checkbox).change(
 function(event) {

// These are the blocks that both get executed on checkbox check
   if (billable_checkbox.checked) {
 billable_hidden.disabled = true;
   } else {
 billable_hidden.disabled = false;
   }
// ^^^

 }
   );
 }
}
/script
/head
body
form
 input id=billable_hidden type=hidden name=billable
value=No /
 input id=billable_checkbox type=checkbox name=billable
value=Yes /
/form
/body
/html

Does anyone have any insight into this one?

If I add 'return;' statements at the end of the blocks, things work as
expected, however I wouldn't expect that I should have to do that.

Thanks for the help,

--
Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844
University of Minnesota Duluth
Information Technology Systems  Services
PGP key 1024D/84E22DA2 2005-11-07
Fingerprint: 78F9 18B3 EF58 56F5 FC85  C5CA 53E7 887F 84E2 2DA2

He is not a fool who gives up what he cannot keep to gain what he cannot
lose.
-Jim Elliot

  





[jQuery] Re: jQuery on IE

2009-07-09 Thread Peter Edwards


Why is the type attribute of the script tag set to

application/x-javascript

rather than

text/javascript

?


on 09/07/2009 21:40 Paulodemoc said::

the address to js is correct, it opens just fine.
I created a new document:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
titleAstral/title
link href=?php echo base_url();?css/style.css rel=stylesheet
type=text/css /
script language=javascript src=?php echo base_url();?js/
jquery.js type=application/x-javascript /script
script
alert($);
/script
/head

body
/body
/html

and it also showed the error message saying that $ is not defined.
but on firefox, it showed:

function (selector, context) {
return new (jQuery.fn.init)(selector, context);
}

u_U (man, i hate IE)

On Jul 9, 5:30 pm, Matt Kruse m...@thekrusefamily.com wrote:
  

So now enter this in IE's address bar:

http://servidor/astral/web/js/jquery.js

Does it load?

If yes, then create this document:

htmlhead
script language=javascript src=http://servidor/astral/web/js/
jquery.js type=application/x-javascript /script
script
alert($);
/script
/head/html

What does it alert?

Make sure IE's settings are such that errors will be shown.

Matt Kruse

On Jul 9, 3:27 pm, Paulodemoc paulode...@gmail.com wrote:



The generated code is
script language=javascript src=http://servidor/astral/web/js/
jquery.js type=application/x-javascript /script
I tryied to add the
alert('jQuery not loaded');
but no alert was shown
But still, the error persists...
I will paste here the full code, so you guys can see:
  
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/

TR/xhtml11/DTD/xhtml11.dtd
html xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=UTF-8 /
titleAstral/title
link rel=stylesheet href=?php echo base_url(); ?css/
thickbox.css type=text/css /
link href=?php echo base_url();?css/style.css rel=stylesheet
type=text/css /
script language=javascript src=?php echo base_url();?js/
jquery.js type=application/x-javascript /script
script language=javascript src=?php echo base_url();?js/
thickbox.js type=application/x-javascript /script
script
 function showSubProdutos() {
$(#submenu).fadeIn(slow);
 };
 function hideSubProdutos() {
$(#submenu).fadeOut(fast);
 };
 function showProjetos() {
$(#submenu2).fadeIn(slow);
 };
 function hideProjetos() {
$(#submenu2).fadeOut(fast);
 };
 function hideAll() {
 $(#submenu).fadeOut(fast);
 $(#submenu2).fadeOut(fast);
 };
 function changeSubject() {
if($(#assunto).find('option').filter(':selected').text() ==
Receita) {
//$(#msg-cont).toggle(2000, function(){ 
$(#recipe-cont).toggle
(2000); });
$(#msg-cont).slideUp(slow, function(){
$(this).hide();
$(#recipe-cont).slideDown(2000);
});
}
else {
$(#recipe-cont).slideUp(slow, function(){
$(#msg-cont).slideDown(slow);
});
}
 };
  
$(document).ready(function(){

 var nome = ;
 var pos = ;
 var html = 
document.createElement(div);
 $(html).attr(id, 
submenu);
 $(html).css(z-index, 
30);
 $(html).css(position, 
relative);
 $(html).css(background-color, 
#D7);
 $(html).css(float, 
left);
 $(html).css(width, 
140px);
 $(html).css(top, 
125px);
 $(html).css(left, 
320px);
 $(html).hide();
 
$(window.document.body).prepend(html);
 
$(html).append(centera href='?php echo base_url
().'index.php/home/produtos';?' style='font-family:Tahoma, Arial,
Helvetica, sans-serif;color:#972021;font-size:11px;line-height:
25px;font-weight:bold;'Linha Domeacute;stica/abr /a href='?php
echo base_url().'index.php/home/produtos_institucionais';?'
style='font-family:Tahoma, Arial, Helvetica, sans-
serif;color:#972021;font-size:11px;line-height:25px;font-
weight:bold;'Linha Institucional/a/center);
html = 
document.createElement(div);
 

[jQuery] Re: PDF + Jquery + thickbox is not suppoting to Mozilla

2009-06-22 Thread Peter Edwards


Hi Bharath,

Your code would never work on my machine (even in IE) as I have set it 
up so PDFs display in a standalone reader (i.e. do NOT use the browser 
plug-in).
Is the problem that the PDF does not download at all in Mozilla under 
some set of circumstances?


Peter

on 22/06/2009 11:10 jazz said::

Hi Folks,

I am facing a severe problem in Mozilla,i.e.i cannot open a pdf in a
frame which users Jquery thickbox.


is there any solution?

Regards,
Bharath

  


[jQuery] Re: Autoselect a checkbox on user's input value

2009-05-26 Thread Peter Edwards


Try this:

$(function(){
 $('#DNnumber').keyup(function(){
   if (parseInt($(this).val())  40) {
 $('#external').attr(checked, checked);
 $('#internal').attr(checked, );
   } else {
 $('#external').attr(checked, );
 $('#internal').attr(checked, checked);
   }
 });
});


on 25/05/2009 13:51 ciupaz said::

Hi all,
I have two checkboxes like these ones:

span
input name=place id=internal type=checkbox
value=internal /Internal (up to DN 40)br /
input name=place id=external type=checkbox
value=external /External (over DN 40)
/span

and a textbox like this:

Insert the DN number:
input name=DNnumber id=DNnumber type=text /

I'd like a sort of validation that when the user insert a DN number
greater than 40, the checkbox external will be automatically
selected (without change it).

How can I accomplish this?

Thanks a lot.

Luigi

  


[jQuery] Re: JQuery css selector

2009-05-18 Thread Peter Edwards

  $('#delete_item a').click(function(){
return (confirm('Are you sure?'));
  });

This will only work if there is one item to delete on the page because 
it uses an ID selector.
If you have multiple items, use a class selector instead.

on 18/05/2009 08:43 ocptime said::
 Hi everyone,

 How can I use the jQuery css selector on click function when the user
 clicks on the delete img
 or the delete  a href tag?

 code
 div id=ribbon
   span class=right
   ul
   li
a href=/items/makeActive/444img src=http://example.com/images/
 checked.gif//a
   a href=/items/makeActive/444Make Active/a
   /li
   li id=delete_item
 a href=/items/delete/444img src=http://example.com/images/
 unchecked.gif //a
   a href=/items/delete/444Delete/a
   /li
   li /li
 /ul
   /span
 /div
 /code

 Thanks everyone,
 ocptime
 

   


[jQuery] Re: JQuery css selector

2009-05-18 Thread Peter Edwards


Take a look at this example:

http://bjorsq.net/selector.html



on 18/05/2009 11:07 ocptime said::

Hi,

It's not working :).
How can i select using the jquery ul li selector?

Thanks
ocptime

On 18 May, 13:39, Peter Edwards p...@bjorsq.net wrote:
  

  $('#delete_item a').click(function(){
return (confirm('Are you sure?'));
  });

This will only work if there is one item to delete on the page because
it uses an ID selector.
If you have multiple items, use a class selector instead.

on 18/05/2009 08:43 ocptime said::



Hi everyone,
  
How can I use the jQuery css selector on click function when the user

clicks on the delete img
or the delete  a href tag?
  
code

div id=ribbon
  span class=right
   ul
  li
a href=/items/makeActive/444img src=http://example.com/images/
checked.gif//a
   a href=/items/makeActive/444Make Active/a
  /li
  li id=delete_item
 a href=/items/delete/444img src=http://example.com/images/
unchecked.gif //a
   a href=/items/delete/444Delete/a
  /li
  li /li
/ul
  /span
/div
/code
  
Thanks everyone,

ocptime
  


  


[jQuery] Re: Conflicts between scripts

2009-05-15 Thread Peter Edwards


You can avoid this conflict altogether (and reduce downloads 
considerably) using slimbox or thickbox


http://www.digitalia.be/software/slimbox (lightbox clone for jQuery)
http://jquery.com/demo/thickbox/ (can use to achieve lightbox effect, 
but much more versatile - can handle anything - not just images)



on 15/05/2009 14:51 Mike said::

There is a problem with loading prototype and jquery on the same
page.  One trick that you can do is bulk replace in interface.js the
'$' with 'jQuery'.  Update all your scripts that use jQuery to replace
the '$'.

Also, remember that on your pages to use 'jquery' rather than '$' when
referencing the jquery components/functions.  This is b/c you have
both prototype and jquery invoked on the same page.


On May 15, 1:14 am, jmCom jasonmont...@new.rr.com wrote:
  

Hello, all.  I am a fairly new web designer and I have the following
attached scripts on my page.  Alone, they (lightbox and jQuery/
interface) work great.  But together, depending on their order in the
head, I get one to work but not the other.  Can anyone tell me if I
am seriously missing something or using outdated scripts...  I am at a
loss here.  Thanks in advance.

!--includes--
script type=text/javascript src=scripts/prototype.js/script
script type=text/javascript src=scripts/scriptaculous.js?
load=effects,builder/script
script type=text/javascript src=scripts/lightbox.js/script
!--for lightbox--
script type=text/javascript src=scripts/jquery-1.3.2.min.js/
script
script type=text/javascript src=scripts/interface.js/script
!--for interface/fisheye--
link href=css/style.css rel=stylesheet type=text/css /!--for
interface/fisheye--
link rel=stylesheet href=css/lightbox.css type=text/css
media=screen /!--for lightbox--
link rel=shortcut icon href=images/site_logo.ico
link href=css/photoshop.css rel=stylesheet type=text/css /!--
for page layout--
!--end includes--



  


[jQuery] Re: how to uncheck the check box

2009-05-15 Thread Peter Edwards


There are a few ways to do this.
You can select by class, in which case you give a group of checkboxes 
the same class


$(function(){
 // attach a click event to each checkbox whose class is 'onechecked'
 $(':checkbox.onechecked').click(function(){
   // if the clicked checkbox is checked (no need to do anything if it 
is being unchecked)

   if (this.checked) {
 // loop through all other checkboxes with the same class
 $(':checkbox.onechecked').each(function(){
   // uncheck all of them
   this.checked = false;
 });
 // re-check the one clicked
 this.checked = true;
   }
 });
});

HTML:
fieldset
input type=checkbox checked=checked name=cb1 class=onechecked /
input type=checkbox name=cb2 class=onechecked /
input type=checkbox name=cb3 class=onechecked /
input type=checkbox name=cb4 class=onechecked /
/fieldset

you can also use the name attribute of the checkbox to group them - this 
could work for multiple groups of checkboxes - this example assumes that 
each group of checkboxes has the same name attribute, and those you want 
to limit to one selection are prefixed 'limit'


$(function(){
 // attach a click event to each checkbox whose name begins with 'limit'
 $(':checkbox[name^=limit]').click(function(){
   // store the name of the checkbox which has been clicked
   var inputname = $(this).attr(name);
   // if the clicked checkbox is checked (no need to do anything if it 
is being unchecked)

   if (this.checked) {
 // loop through all other checkboxes with the same name attribute 
as the one clicked

 $(':checkbox[name='+inputname+']').each(function(){
   // uncheck all of them
   this.checked = false;
 });
 // re-check the one clicked
 this.checked = true;
   }
 });
});

HTML:
fieldset
input type=checkbox checked=checked name=limit1 /
input type=checkbox name=limit1 /
input type=checkbox name=limit1 /
input type=checkbox name=limit1 /
/fieldset
fieldset
input type=checkbox checked=checked name=limit2 /
input type=checkbox name=limit2 /
input type=checkbox name=limit2 /
input type=checkbox name=limit2 /
/fieldset

There are other ways as well, but this should give you some idea about 
some of the possibilities.


on 15/05/2009 15:48 elubin said::

add a click handler to each checkbox (you could use a selector and
loop through with $.each).  when clicked, the function could use the
same selected and loop through again making sure the others are off.

Eric



On May 15, 10:38 am, bharani kumar bharanikumariyer...@gmail.com
wrote:
  

Hi all

Can u tell me , how to uncheck the check box , when i check another check
box,

for example

having 4 check boxes,

be default check box is checked ,.

when i check the check box 2 , then need to uncheck the checked one ,

How to do this in jquery ,

Thanks

--
உங்கள் நண்பன்
பரணி  குமார்

Regards
B.S.Bharanikumar

POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/



  


[jQuery] Re: jQuery Ajax SUCCESS: using 'THIS'?

2009-05-01 Thread Peter Edwards


Hi Roman,

You need to copy the reference to your link to a variable like this:

jQuery('#yt1').click(function(){
 $(this).replaceWith(iApproving.../i);
 var aObj = $(this);
 jQuery.ajax({
   'type':'POST',
   'data':'id=205',
   'dataType':'text',
   'success':function(msg){
 alert(aObj.attr(id));
   },
   'url':'/approve/article',
   'cache':false
 });
 return false;
});


on 01/05/2009 11:48 phpdevmd said::

Hello, I have the following jquery ajax request:

html
head
script type=text/javascript src=jquery-1.3.2.min.js/script
/head
body
a href=# id=yt1Approve/a
script type=text/javascript
/*![CDATA[*/
jQuery(document).ready(function() {
jQuery('#yt1').click(function(){
  $(this).replaceWith(iApproving.../i);
  jQuery.ajax({
'type':'POST',
'data':'id=205',
'dataType':'text',
'success':function(msg){
  alert($(this).attr(id));
},
'url':'/approve/article',
'cache':false
  });
  return false;
});
});
/*]]*/
/script
/body
/html

First replaceWith working fine, link changes to 'Approving', but alert
saying 'undefined' instead of 'yt1'...
Any ideas acessing this link in a script where I don't know exactly
what id does this link have?
I know that alert($(#yt1).attr(id)); would work, but 'yt1' is auto-
generated by my framework, so I need to access it without $(#_id_)
but using 'this' or any other appropriate method.

Thanks in advance.
Roman

  


[jQuery] Re: How to prevent loading jquery twice

2009-03-23 Thread Peter Edwards


Are you using joomla to load jQuery? or are you wringin script tags in 
some sort of template?

I came across this:
http://www.packtpub.com/article/using-javascript-effects-with-joomla
which seems to imply joomla can handle you script inclusion.
hope this helps

on 23/03/2009 11:41 Andy789 said::

also, it is working (only in FF, though) and not very stable. I think
what is happening, when I write the script.../script reference to
the header, it does not mean that it is loaded. in fact, it is loaded
SOMETIMES

On Mar 23, 10:28 pm, Andy789 e...@abcstudio.com.au wrote:
  

we are talking about joomla's index.php (used as a main page) and
index2.php (used as an iframe). Index2.php is always a part of
index.php. Therefore,

1) if I include jquery to the main page header, the iframe (generated
as index2,php) will not work as there is no jquery in there
2) if I include it to both headers, i will get a double library
3) if I include it only to the iframe part, which is always a part of
the main page, it will work OK, but i will be changing the core
joomla's files and will have to hack it every time when a new version
is out

So, I am trying to load it only, if it has not been loaded before.
Does it make sense now?

On Mar 23, 10:15 pm, Liam Potter radioactiv...@gmail.com wrote:



well, the onesloadingthrough the iframe will need jquery loaded in the
iframe, and the components loaded one-by-one only need jquery loaded once..
  
I don't understand what you are trying to do hre, just load jquery in

the head.
  
Andy789 wrote:
  

Because some components are loaded inside of iframe and need its own
jQuery. some compionents are loaded one-by-one and need only one
common library

On Mar 23, 9:39 pm, Liam Potter radioactiv...@gmail.com wrote:


why would you beloadingthe library for each script?
  
Andy789 wrote:
  

Hi all,

I have different independent modules using jquery and need to avoid

its doubleloading. So, instead ofloadingjquery, I amloadingthe
code:

if (typeof jQuery != 'undefined') {

document.write('script type=text/javascript src=/templates/
yoo_evolution/lib/js/jquery-1.3.2.min.js/script');
}

Also, I have added a line var $j = jQuery.noConflict(); as a last line

of jquery library file.

The problem is that though it writes the code on document write, it

does not seem that jquery is loaded at all, because I am getting an
error  jQuery not defined.

What am i doing wrong here? is there a more elegant way to load a

library dynamically?

Thanks



  


[jQuery] Re: OnMouseDown = create draggable, OnMouseUp = create droppable

2009-03-09 Thread Peter Edwards


Have you tried the jQuery UI mailing list?
Why not create draggable and droppable at the same time?
The way I understand it, a draggable is created so it can be dropped on 
a droppable, so the two are linked and it makes sense to create them at 
the same time.

Or do you need to create hundreds of droppables for each draggable?
Some example code or a link to an example may help get some responses to 
your question, and would probably help me to answer your first question 
about the mouse position problem you are having.


on 09/03/2009 06:56 delphilynx said::

Thanks for the answer Karl Rudd,

But that is what I already have tried. If you read the start post,
then you see that I want to create the drag and dropable on runtime.
If there is something what is not clear, please say it.

Thanks again if someone is willing to read the start post and then
point me in the right direction.

  


[jQuery] Re: One page site multipage degradation

2009-02-13 Thread Peter Edwards


I don't know why IE does this but you shouldn't need to re-write the 
href attribute anyway - I'm assuming you attach a click event to the 
buttons to load content, so just return false from the click event 
handler and the link won't be followed - you can leave the href 
attribute intact.


$(.btnNavigation).click(function(){
 // all the AJAX stuff to load content into the page
 return false;
});




on 13/02/2009 11:42 Fluffica said::

Morning all,

I'm working on a large single page site at the moment. I've seen these
around before quite happily using a href=#page type mark up,
leaving jQuery to control loading the content in dynamicly and so on.

However, our solution to both graceful degradation and a worry that
Google doesn't class one page websites as websites was to have a
href=page.html class=btnNavigation, leaving those without
javascript enabled using a tradiaional website which went from .html
to .html. While the js would contain  $(.btnNavigation).attr
({href:#}); promting those with javascript to remain on index.html#,
and let jQuery load in our content into that page.

This works lovely in all browsers but internet explorer (naturally),
which sends us straight to page.html, instead of index.html#

Does anyone have any suggestions as to why Internet Explorer is
ignoring this request? Or is there a better way I should be trying to
work this?

Huge thanks in advance,
Tom.

  


[jQuery] Re: how to differentiate between click and dragend events?

2009-02-11 Thread Peter Edwards


the event order is mousedown-mouseup-click
the 'dragend' event is triggered by mouseup, which happens before the 
click event, so if you put logic in your function dragged() to prevent 
clicked() from doing whatever it does, then the click event which is 
triggered at the end of a drag should be neutralised. The following 
approach uses a global boolean variable as a switch.


var afterDrag = false
function draggged() { afterDrag = true; }
function clicked(){
 if (afterDrag) {
   afterDrag = false;
   return;
 }
}

Another approach would be to cancel events in the dragged() function 
somehow, but my knowledge of the event model doesn't extend that far 
(can a mouseup event cancel the click event which follows it?)



on 12/02/2009 00:43 legofish said::

no takers?

On Feb 11, 1:54 pm, legofish pen...@gmail.com wrote:
  

Hi,

I am using the drag plugin (http://blog.threedubmedia.com/2008/08/
eventspecialdrag.html) to design some interactions for a UI element.

The element foo, needs to respond to a click, as well as to a drag
(different responses for each). The plugin gives you handy drag events
to work with.

So I have:
$(#foo).bind('dragend', function(e){   dragged()   });
$(#foo).bind('click', function(e){   clicked()   });

When foo is simply clicked on, then clicked() is executed and all is
well.
However, when foo is dragged, dragged() is called and right after that
clicked() is called as well.
I don't want clicked() to be called when foo is dragged, but I can't
seem to figure out how to avoid that. Help is much appreciated.



  


[jQuery] Re: Hide specific characters

2009-01-23 Thread Peter Edwards


Try this:

$(.cartSummaryItem).each(function(){
   $(this).html($(this).html().replace(/,[^]*/, ' '));
});

It takes the html content of the cartSummaryItem table cell, and 
replaces everything from the comma to the start of the View Cart link 
with a space, then resets the contents of the table cell with the 
results. You could do it with a more complex regular expression, but you 
already have two delimiters (the comma and the start tag of the link) so 
there's no need.




on 23/01/2009 00:53 Wacko Jacko said::

Hi There,

I am using a CMS product that does not enable me to hide cart totals
from their cart summary. I need to do this for this particular client.

Here a snippet of code for the rendered page:

span id=catCartSummary quote=False vertical=Falsetable
cellspacing=0  class=cartSummaryTabletrtd
class=cartSummaryItem2 item(s), Total: $0.00 a
class=cartSummaryLink href=/OrderRetrievev2.aspx?
CatalogueID=34987View Cart/a/td/tr/table/span

I would like to hide (or remove) from the exact following section: ,
Total: $0.00\

So everything from the 'comma', the word 'Total' and all other numbers
and the $ sign. The 'View cart' I am already replacing with the
following code:

$(document).ready(function() {
$(.cartSummaryLink).html(View enquiry list);
});

Thanks in advance for your help.


  


[jQuery] Re: Need some help with image map coding....

2008-09-19 Thread Peter Edwards

Hi Aaron,

The following code should help:

$(document).ready(function(){
$('area').each(function(){
$(this).attr(href, #);
$(this).click(function(){
$('#ajaxresult').load('map.php', {'state':$(this).attr('alt')});
 return false;
});
});
});

What it does:
1. select all the area elements on the page
2. clear the href attribute
3. assign a click event to each area which
4. loads the result of an AJAX POST to a php script (map.php) in the 
element with ID ajaxresult.

In the example, I've used the alt attribute of the area tag for the name 
of the state (which is POSTed to the php script). I've also made all 
area tags on the page behave like this - if you have other image maps on 
the page, then they will be affected too. If you want to replace the 
image map with something from your PHP script, make sure the image and 
imagemap are in a container div, then load the output of the PHP script 
into the container div (you should empty the container first).

HTH



on 18/09/2008 16:24 Aaron said::
 well what can I do to use javascript  to submit a name to my php
 code???

 I want to use the image map as a gui so I want it to act just like a
 form where I can name each state and then pass that name using post
 method to my php script which will do a database lookup and then once
 the list is create then I will take off the image map and put in the
 table with the list displayed.

 this is what I want to do but I can't figure out how I can pass the
 name to my php script...


   


[jQuery] Re: $.post callback problem

2008-09-12 Thread Peter Edwards

It looks like you have a rogue parenthesis to me - 
$.post($(this).attr(href)) - the last closing parenthesis completes 
the $.post call, so your callback function will not fire.

on 11/09/2008 21:49 Tom Shafer said::
 i am trying to use data i am getting back from $.post but I am not
 able to get the function with the data in it to work



 $(a.rater).click(function(event)
   {
   $.post($(this).attr(href)),
   function(data)
   {
  update = data.split('|');
 $('#'update[0]).replaceWith(update[1]);
   };
   return false;
   }
 );

 i also tried

 $(a.rater).click(function(event)
   {
   $.post($(this).attr(href)),
   function(data)
   {
 alert(+data);
   };
   return false;
   }
 );

 any suggestions?



   


[jQuery] Re: attr('form') not work in firefox

2008-05-19 Thread Peter Edwards

I don't think it is correct to call this an attribute, as this implies 
that you can specify it in the HTML (it is not an allowed attribute in 
the W3C specification). It should be a cross-browser property of all 
form elements though.

on 19/05/2008 15:54 Ariel Flesler said::
 No, you're right. Form elements (input, select, textarea, etc) do have
 a 'form' attribute. I think it's even cross-browser.
 Your code WILL work with the new version (1.2.4) which will be
 (hopefully) released soon.
 
 If you want to verify this will work, you can get it by doing a
 checkout:
  http://code.google.com/p/jqueryjs/source/checkout
 And building it yourself.
 
 $().attr() will be much more intuitive and reliably (I hope so) from
 now on.
 
 Cheers
 
 --
 Ariel Flesler
 http://flesler.blogspot.com
 
 On 19 mayo, 10:55, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Thanks all, it must be my misunderstanding of the dom.
 


[jQuery] Re: events on embedded SVG

2008-03-25 Thread Peter Edwards

The SVG DOM is different to the HTML DOM (which jquery was written for) 
- a lot of things are the same, so you may have some luck using jquery 
in SVG (there are some threads dealing with SVG related issues in this 
list which should give you an indication of what to look out for).

In the last SVG project I was involved in, I treated the SVG and HTML 
completely separately, mainly because:
1. I could not find a way to access the SVG DOM from HTML in Safari.
2. I wanted to use AJAX, and needed to do it the same way across SVG 
implementations (using getURL in Adobe SVG viewer and XMLHttpRequest in 
others), so the AJAX code I needed had to be separate from the AJAX code 
used in the HTML pages.
3. I found that embedding the SVG file was best achieved in different 
ways across different browser/viewer configurations 
(object/embed/iframe) - this was mainly a source of annoyance, but made 
me feel that It would be best to separate the two from each other 
completely.

I think if I wanted to use jQuery in SVG, I would get the source and try 
to port it (or the parts I was interested in using) to the SVG DOM so 
all HTML/CSS and browser-related fixes were discarded and fixes for 
different viewers put in place instead. This would be made much easier 
if you target a single browser implementation (such as Firefox or Opera) 
- trying to take into account the differences between different SVG 
viewer/browser combinations is quite a task, and one I abandoned quite 
early.

Hope this helps.

on 24/03/2008 10:26 zipman said::
 Anyone?
 
 On Mar 23, 8:02 pm, zipman [EMAIL PROTECTED] wrote:
 Hello,

 I am having an html page and I embed an svg file through.

 object id=map data=/Demo/map.svg type=image/svg+xml
 height=500 width=600
 /object

 or even

 embed id=map src=/Demo/map.svg type=image/svg+xml height=500
 width=600

 The problem is that I cannot access the elements inside the svg file
 through jquery.

 I can do

  htmlObj = document.getElementById(map);
  /*//this works only in IE
   SVGDoc = htmlObj.getSVGDocument();*/

 //this works in firefox
  SVGDoc = htmlObj.contentDocument;

 and then access any element by getElementById

 eg when I want to access an elements with id=test
 I do it by SVGDoc.getElementById('test');

 The problem is that the contents of the SVG are not appended to the
 DOM
 tree so methods like $('#test') do not work.

 Is there any way to make this work?
 


[jQuery] Re: slidetoggle jumps in IE

2008-03-09 Thread Peter Edwards

You could write out a style rule in your script to hide them:
dcoument.write('style type=text/css.sub_section 
{display:none;}/style');
Or set display to none in some other way (using script so the page is 
rendered correctly in non-javascript browsers).

on 08/03/2008 23:36 rocksou said::
 I am having an issue with the way a slidetoggle animation works in
 IE.  I am using the animation to show/hide div's here:
 http://stonebergdesign.com/clients/coop_test/wordpress/about/
 in FF and Safari the animation works great.  In IE the div briefly
 display before and after it shows/hides.  I am not a whiz at jquery
 and most of the code was copied and pasted...  Any help is greatly
 appreciated.