[jQuery] Re: best way to pass parameters to .load()

2008-11-05 Thread Choan Gálvez


Hi.

On Nov 5, 2008, at 1:02 AM, HiddenPhoenix wrote:



is there a difference in passing parameters to .load

$(#myDiv).load(myScript.php?var=xvar2=yvar3=z)

vs

$(#myDiv).load(myScript.php, {var:x, var2:y, var3:z})


In the first case, a GET request is performed. In the latter, the  
request is POSTed.




also is there a size limit to how much .load can handle? can
myScript.php return a couple hundred rows of data without issue?


You can return as much data as you want, it won't be a problem. But,  
adding lots of nodes to the document can be time consuming.


--
Choan


[jQuery] Re: Problems with the JSON return from the jQuery.ajax() method

2008-11-05 Thread Choan Gálvez


Hi.

On Nov 4, 2008, at 10:48 PM, Augusto TMW wrote:



Hi,

I'm trying do return a JSON with a $.ajax() method.

here is my entire function:

function carregaMes(d){
 if(!(_reunioes[reg+d.month+d.year])){
$.ajax({
url: reunioes.jsp,
data: mes=+d.month+ano=+d.year,
async: false,
dataType: json,
success: function(a){
_reunioes[reg+d.month+d.year] = a;
}
});
return _reunioes[reg+d.month+d.year];
 } else {
return _reunioes[reg+d.month+d.year];
 }
}

Where _reunioes is an array in window object.

In FF its ok, but in IE its return undefined. I tried to call a
normal ajax and use the jQuery.httpData() method to covert my xhr into
a JSON, but my IE tell me that in line where jQuery tries to convert
( data = eval((+data+)); ) has an error Indentifier, sequency or
number expected.


I'd bet the input is not valid JSON. Check for extra commas at the end  
of your JSON array definition.


Best.
--
Choan


[jQuery] Re: Google Charts

2008-11-05 Thread Choan Gálvez


On Nov 5, 2008, at 5:59 AM, moscorp wrote:



gchart can't recognize series data in barVert...

can't work in
var valueArray = $('#mpngicnt').text(); //80,30,50
series: [ $.gchart.series([ valueArray ], 'red')],

but it works in
series: [ $.gchart.series([ 80,30,50 ], 'red')],

how can i solve it !


`$('selector').text()` returns a string. From what I read in your  
working code, you need to pass an array.


var valueArray = $.trim($('#mpngicnt').text()).split(','); //  
[ 80, 30, 50 ]

// I assume there is some code in the middle
series: [ $.gchart.series(valueArray, 'red')]

Now, back to jQuery related posts.
--
Choan


[jQuery] Re: Clone problem in IE...

2008-11-05 Thread Choan Gálvez


On Nov 5, 2008, at 6:53 PM, Rafael Soares wrote:


I had a similar problem...
The difference is that I'm trying to clone the file input inside the  
same

document, just another, hidden, form.
I found a workaround, but I don't know if it'll work for you as well.

Since I was going to clear the form after the whole thing anyway, I  
decide
to do the inverse: append the original input to the new form, then  
clone it

and then append the clone to the original form.
It's kinda messy, but worked for me. Of course I'm doing this only  
in IE,

other browsers use the normal procedure.


You are not alone. I had to do just the same. Nasty.







Hope it helps.

Rafael Soares


On Thu, Jul 24, 2008 at 12:10, Marcus Eby [EMAIL PROTECTED] wrote:



I just found out that cloneNode doesn't pass the value in a file  
field

when being cloned from inside an iframe in IE.
Apparently this is an IE bug, and I've tried over 15 different ways  
of

trying to clone the object, then change the values, and update the
values, and even changing them before they get cloned, but nothing
works.

After trying so many different options, and still having no value
being cloned, so that the function won't work, I have given up.

If anyone else has had this problem and solved it, please post.

After spending years hating IE, this has definitely helped me to  
start

thinking about FF only site-app design. grin

Thanks

Marcus





[jQuery] Re: event.preventDefault() seems to fail

2008-10-17 Thread Choan Gálvez


On Oct 17, 2008, at 7:37 PM, ricardobeat wrote:



It should work... but in jQuery 'return false' is the standard cross-
browser way of preventing the default action anyway,


Not exactly.

- `preventDefault()` **is** the cross-browser way of preventing the  
default action.


- `return false` prevents the default action and stops the event  
propagation.





On Oct 16, 11:16 pm, Hullah [EMAIL PROTECTED] wrote:

I have a page with input textboxes and input buttons on it.  All are
contained in a form.  I don't want the Enter button to submit the
form, so I call preventDefault() on all texboxes.  I also don't want
the input button to submit the form, so I call preventDefault() on  
the

input button.

But, if I call the button.click() event for when Enter is pressed  
in a

textbox (to simulate a click on the button) it submits the form.  It
seems as if something is not working like it should.

Now...if I return false instead of preventDefault(), it works as I
would expect.  But I would have thought that the purpose of
preventDefault() is to cancel the default action of the event, as in
this case to cancel form submission.

Any help with this is greatly appreciated!  Following is some sample
code that exhibts the behavoir.

Thanks,
Hullah

!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
titleTest/title
script language=javascript type=text/javascript
src=jquery-1.2.6.js/script
script language=javascript type=text/javascript
  $(function() {
$(:text).keypress(function(e) {
  if (e.which == 13) {
e.preventDefault();
  }
});
$(#txt).keypress(function(e) {
  if (e.which == 13) {
$(#btn).click();
  }
});
$(#btn).click(function(e) {
  e.preventDefault();
  alert(Button clicked);
});
  });
/script
/head
body
  form method=post action=test.html
div
  input id=txt type=text /
  input id=btn type=submit value=Submit /
/div
  /form
/body
/html




[jQuery] Re: event.preventDefault() seems to fail

2008-10-17 Thread Choan Gálvez


On Oct 17, 2008, at 11:22 PM, Hullah wrote:



I would think preventDefault() is the right way to do it too.

So, given that this isn't working like I would have thought it should,
did I code this incorrectly? Or is this something more serious like a
bug?


While I don't fully understand what you want to do, I suspect that  
what you need is the `triggerHandler` method. See http://docs.jquery.com/Events/triggerHandler 
.


Or... submit the form instead of clicking the button.






On Oct 17, 4:36 pm, Choan Gálvez [EMAIL PROTECTED] wrote:

On Oct 17, 2008, at 7:37 PM, ricardobeat wrote:



It should work... but in jQuery 'return false' is the standard  
cross-

browser way of preventing the default action anyway,


Not exactly.

- `preventDefault()` **is** the cross-browser way of preventing the
default action.

- `return false` prevents the default action and stops the event
propagation.




On Oct 16, 11:16 pm, Hullah [EMAIL PROTECTED] wrote:
I have a page with input textboxes and input buttons on it.  All  
are

contained in a form.  I don't want the Enter button to submit the
form, so I call preventDefault() on all texboxes.  I also don't  
want

the input button to submit the form, so I call preventDefault() on
the
input button.



But, if I call the button.click() event for when Enter is pressed
in a
textbox (to simulate a click on the button) it submits the form.   
It

seems as if something is not working like it should.


Now...if I return false instead of preventDefault(), it works  
as I

would expect.  But I would have thought that the purpose of
preventDefault() is to cancel the default action of the event, as  
in

this case to cancel form submission.


Any help with this is greatly appreciated!  Following is some  
sample

code that exhibts the behavoir.



Thanks,
Hullah



!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
titleTest/title
script language=javascript type=text/javascript
src=jquery-1.2.6.js/script
script language=javascript type=text/javascript
  $(function() {
$(:text).keypress(function(e) {
  if (e.which == 13) {
e.preventDefault();
  }
});
$(#txt).keypress(function(e) {
  if (e.which == 13) {
$(#btn).click();
  }
});
$(#btn).click(function(e) {
  e.preventDefault();
  alert(Button clicked);
});
  });
/script
/head
body
  form method=post action=test.html
div
  input id=txt type=text /
  input id=btn type=submit value=Submit /
/div
  /form
/body
/html







[jQuery] Re: binding events and keep reference to the this object

2007-09-08 Thread Choan Gálvez


On 07/09/2007, at 18:35, Michael Geary wrote:


Use a closure.


Or bring your own `bindAsEventListener` into play.

Something like

Function.prototype.bindAsEventListener = function(o) {
var _m = this;
var args = [].slice.call(arguments, 0);
var obj = args.shift();
return function(e) {
return _m.apply(obj, [e, this].concat(args));
}
};

function SomeClass() {
// constructor code
}

SomeClass.prototype.clickHandler = function(e, el) {
// `e` points to the Event object
// `el` points to the element which the handler is assigned to
	// `this` points to whatever we set it to (an instance of SomeClass,  
for example)

};

var myObject = new SomeClass();

$('selector').bind('click', myObject.clickHandler.bindAsEventListener 
(myObject));









From: [EMAIL PROTECTED]

I'm not sure if I've completely missed this in the docs, but
I'm wondering if there is an easier way of achieving the following:

$(.button).bind(click, {that:this}, function(event) {
  var that = event.data.that;
  that.handleEvent();
  return false;
});

I could do the same thing in prototype using bindAsEventListener
like this:

Event.observe($$(.button), 'click',
this.handleEvent.bindAsEventListener(this));

This would help tidy everything up a lot, since I'd like to
maintain a class-based pattern where this is used a lot.
Passing it in as event data seems like overkill.

Thanks :)





--
Choan Gálvez
[EMAIL PROTECTED]
http://choangalvez.nom.es/