[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-20 Thread Mark

and i'm giving those 2!

Here is the full stuff again (posted in my last and first post as well)

Javascript:
function removeItem(name, obj)
{
   var answer = confirm("Are you sure you want to delete: " + name + "?")
   var test = obj;

   if (answer)
   {
   $(test.parentNode.parentNode).fadeOut("slow");
   }
}

HTML(not working):
click

HTML(working):
click

As you can see.. with both i give what it needs but yet the  wrote:
>
> How are you calling "removeItem" ?
>
> It needs two parameters - the name and the object reference.
>
> Liam
>
> Mark wrote:
>>
>> hey,
>>
>> function removeItem(name, obj)
>> {
>>var answer = confirm("Are you sure you want to delete: " + name + "?")
>>var test = obj;
>>
>>if (answer)
>>{
>>$(test.parentNode.parentNode).fadeOut("slow");
>>}
>> }
>>
>> the code is simple and still not working.. the issue is that i try to
>> call a variable in a if that wasn't made there.. but how can i resolve
>> that?
>> Why is javascript not working how you would expect it to work :S i
>> know Java and PHP well and things like this are no issue in them.
>>
>> o and in this code i already put obj in test.. i've tried it with obj
>> first but that gave the same error as in the title.
>>
>> Thanx.
>>
>>
>>
>
>


[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-20 Thread Liam Byrne


How are you calling "removeItem" ?

It needs two parameters - the name and the object reference.

Liam

Mark wrote:

hey,

function removeItem(name, obj)
{
var answer = confirm("Are you sure you want to delete: " + name + "?")
var test = obj;

if (answer)
{
$(test.parentNode.parentNode).fadeOut("slow");
}
}

the code is simple and still not working.. the issue is that i try to
call a variable in a if that wasn't made there.. but how can i resolve
that?
Why is javascript not working how you would expect it to work :S i
know Java and PHP well and things like this are no issue in them.

o and in this code i already put obj in test.. i've tried it with obj
first but that gave the same error as in the title.

Thanx.


  




[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-20 Thread Mark

On Fri, Jun 20, 2008 at 1:51 AM, Josh Nathanson <[EMAIL PROTECTED]> wrote:
>
>> Now why is this not working with a href?
>> I have just no clue.
>
> My guess is that the context doesn't resolve correctly when you do
> "javascript:" in the href, so when you do "this.parentNode", it probably
> thinks "this" is the window object, which doesn't have a parent node.  Thus
> it returns undefined.
>
> When you do "onclick" it knows the context is that "a" node so it works
> properly.
>
> Also, if you are getting into jQuery, I'd suggest learning a little bit
> about "unobtrusive javascript", that is, not putting your event handler code
> inline.  This helps you keep your html markup and your JS code separated.

what do you mean by: "not putting your event handler code inline"
And my javascript code is in a seperate .js file. but i have to call
it somewhere in the html and that's what you see in the href and
onclick. And i will take a look at that "unobtrusive javascript" but
any suggestions for good docs about that?

>
> -- Josh
>
>
> ----- Original Message - From: "Mark" <[EMAIL PROTECTED]>
> To: 
> Sent: Thursday, June 19, 2008 4:13 PM
> Subject: [jQuery] Re: Why do i keep getting: test is not defined!
>
>
>>
>> Thanx for the fast reply!
>> I just now found why it was not working..
>>
>> With this it works:
>> click
>>
>> with this not (will give the freaking error):
>> click
>>
>> Now why is this not working with a href?
>> I have just no clue.
>>
>>
>> On Fri, Jun 20, 2008 at 1:08 AM, Josh Nathanson <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> Your function is fine, however when you *call* the function removeItem,
>>> you'll need to pass in two arguments -- otherwise obj will be undefined:
>>>
>>> removeItem('myitem'); // obj is undefined
>>> removeItem('myitem', myobject); // obj is defined
>>>
>>> -- Josh
>>>
>>>
>>> - Original Message - From: "Mark" <[EMAIL PROTECTED]>
>>> To: 
>>> Sent: Thursday, June 19, 2008 4:02 PM
>>> Subject: [jQuery] Why do i keep getting: test is not defined!
>>>
>>>
>>>>
>>>> hey,
>>>>
>>>> function removeItem(name, obj)
>>>> {
>>>>  var answer = confirm("Are you sure you want to delete: " + name + "?")
>>>>  var test = obj;
>>>>
>>>>  if (answer)
>>>>  {
>>>>  $(test.parentNode.parentNode).fadeOut("slow");
>>>>  }
>>>> }
>>>>
>>>> the code is simple and still not working.. the issue is that i try to
>>>> call a variable in a if that wasn't made there.. but how can i resolve
>>>> that?
>>>> Why is javascript not working how you would expect it to work :S i
>>>> know Java and PHP well and things like this are no issue in them.
>>>>
>>>> o and in this code i already put obj in test.. i've tried it with obj
>>>> first but that gave the same error as in the title.
>>>>
>>>> Thanx.
>>>
>>>
>
>


[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-19 Thread Josh Nathanson



Now why is this not working with a href?
I have just no clue.


My guess is that the context doesn't resolve correctly when you do 
"javascript:" in the href, so when you do "this.parentNode", it probably 
thinks "this" is the window object, which doesn't have a parent node.  Thus 
it returns undefined.


When you do "onclick" it knows the context is that "a" node so it works 
properly.


Also, if you are getting into jQuery, I'd suggest learning a little bit 
about "unobtrusive javascript", that is, not putting your event handler code 
inline.  This helps you keep your html markup and your JS code separated.


-- Josh


- Original Message - 
From: "Mark" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, June 19, 2008 4:13 PM
Subject: [jQuery] Re: Why do i keep getting: test is not defined!




Thanx for the fast reply!
I just now found why it was not working..

With this it works:
click

with this not (will give the freaking error):
click

Now why is this not working with a href?
I have just no clue.


On Fri, Jun 20, 2008 at 1:08 AM, Josh Nathanson <[EMAIL PROTECTED]> 
wrote:


Your function is fine, however when you *call* the function removeItem,
you'll need to pass in two arguments -- otherwise obj will be undefined:

removeItem('myitem'); // obj is undefined
removeItem('myitem', myobject); // obj is defined

-- Josh


- Original Message - From: "Mark" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, June 19, 2008 4:02 PM
Subject: [jQuery] Why do i keep getting: test is not defined!




hey,

function removeItem(name, obj)
{
  var answer = confirm("Are you sure you want to delete: " + name + "?")
  var test = obj;

  if (answer)
  {
  $(test.parentNode.parentNode).fadeOut("slow");
  }
}

the code is simple and still not working.. the issue is that i try to
call a variable in a if that wasn't made there.. but how can i resolve
that?
Why is javascript not working how you would expect it to work :S i
know Java and PHP well and things like this are no issue in them.

o and in this code i already put obj in test.. i've tried it with obj
first but that gave the same error as in the title.

Thanx.







[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-19 Thread Mark

Thanx for the fast reply!
I just now found why it was not working..

With this it works:
click

with this not (will give the freaking error):
click

Now why is this not working with a href?
I have just no clue.


On Fri, Jun 20, 2008 at 1:08 AM, Josh Nathanson <[EMAIL PROTECTED]> wrote:
>
> Your function is fine, however when you *call* the function removeItem,
> you'll need to pass in two arguments -- otherwise obj will be undefined:
>
> removeItem('myitem'); // obj is undefined
> removeItem('myitem', myobject); // obj is defined
>
> -- Josh
>
>
> - Original Message - From: "Mark" <[EMAIL PROTECTED]>
> To: 
> Sent: Thursday, June 19, 2008 4:02 PM
> Subject: [jQuery] Why do i keep getting: test is not defined!
>
>
>>
>> hey,
>>
>> function removeItem(name, obj)
>> {
>>   var answer = confirm("Are you sure you want to delete: " + name + "?")
>>   var test = obj;
>>
>>   if (answer)
>>   {
>>   $(test.parentNode.parentNode).fadeOut("slow");
>>   }
>> }
>>
>> the code is simple and still not working.. the issue is that i try to
>> call a variable in a if that wasn't made there.. but how can i resolve
>> that?
>> Why is javascript not working how you would expect it to work :S i
>> know Java and PHP well and things like this are no issue in them.
>>
>> o and in this code i already put obj in test.. i've tried it with obj
>> first but that gave the same error as in the title.
>>
>> Thanx.
>
>


[jQuery] Re: Why do i keep getting: test is not defined!

2008-06-19 Thread Josh Nathanson


Your function is fine, however when you *call* the function removeItem, 
you'll need to pass in two arguments -- otherwise obj will be undefined:


removeItem('myitem'); // obj is undefined
removeItem('myitem', myobject); // obj is defined

-- Josh


- Original Message - 
From: "Mark" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, June 19, 2008 4:02 PM
Subject: [jQuery] Why do i keep getting: test is not defined!




hey,

function removeItem(name, obj)
{
   var answer = confirm("Are you sure you want to delete: " + name + "?")
   var test = obj;

   if (answer)
   {
   $(test.parentNode.parentNode).fadeOut("slow");
   }
}

the code is simple and still not working.. the issue is that i try to
call a variable in a if that wasn't made there.. but how can i resolve
that?
Why is javascript not working how you would expect it to work :S i
know Java and PHP well and things like this are no issue in them.

o and in this code i already put obj in test.. i've tried it with obj
first but that gave the same error as in the title.

Thanx.