[jQuery] Re: How to make an element *not* have a function attached...

2009-02-14 Thread QuadCom

Here's my understanding.


unbind will work for events. The expandable function you applied is
not an event. What I would do in this instance is on the hide button,
remove the textarea with the expandable and then insert a new textarea
with the same id. That would appear to remove the expandable
attributes.

Don't forget, if there is text in the textarea, copy it to a var
first, then do the remove/add step.

You could write your own plugin to do all o that in one step ie.
unexpandable



On Feb 13, 3:39 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Nice try, but no prize yet...

 Given these scripts:

 $(document).ready(function() {
  $('#myTextarea').hide();

 });

 $(document).ready(function() {
  $('#hide').click(function() {
   $('#myTextarea').unbind().slideUp();
   return false;
  });

 });

 $(document).ready(function() {
  $('#show').click(function() {
   $('#myTextarea').expandable().slideDown();
   return false;
  });

 });

 and this HTML:

 div style=padding-left:100px;

  p[ strongNotes concerning textarea/strong ]
 [ notes ]
 [ a id=hide href=#hide/a ]
 [ a id=show href=#show/a ]
 [ export ]
 [ clear ]
  /p

  textarea id=myTextarea cols=100/textarea

 /div

 Why wouldn't your idea work, Josh?
 It makes sense to me.

 I can click #show and #myTextarea becomes .expandable and executes .slideDown.
 But, when I then click #hide and #myTextarea starts to execute .slideUp,
 but then expands again, as it would if .expandable were still bound to it.

 Should I code this differently?

 Thanks,

 Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Josh Nathanson
  Sent: Friday, February 13, 2009 3:00 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: How to make an element *not* have a function 
  attached...

  This should work:

  $('#myTextarea').unbind(); // unbinds all handlers

  Then when you want to bind it again:

  $('#myTextarea').expandable();

  -- Josh

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
  Behalf Of Rick Faircloth
  Sent: Friday, February 13, 2009 11:43 AM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: How to make an element *not* have a function
  attached...

  To answer your question, hopefully, the element, in this case a textarea,
  is set up like this:

  script

   $(function() {
$('#myTextarea').expandable();
 });

  /script

  ...and that's it.  It would be active as expandable all the time.

  So, there's no event, like click, etc., that triggers the function.

  However, I want to be able to click a link and disable the expandable
  functionality, until another link is clicked to re-enable the functionality.

  In other words, having the textarea expandable is not something I want
  on all the time.

   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
  Behalf Of Frederik Ring
   Sent: Friday, February 13, 2009 2:04 PM
   To: jQuery (English)
   Subject: [jQuery] Re: How to make an element *not* have a function
  attached...

   This should be done using $(this).unbind(event,function).
   I don't know from your example how your handle the event so I cannot
   give you a more specific answer.

   On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
Strange question, perhaps...but...

If I have an element that has an function from a plug-in
attached to it, such as:

$(function() {
$('#myTextarea').expandable();

});

How would I then be able to make #myTextarea not .expandable...

$('#myTextarea').expandable('disable'); ...

Is this something that can be controlled from the page code, or
does something have to be built into the plug-in to allow this?

Thanks,

Rick


[jQuery] Re: How to make an element *not* have a function attached...

2009-02-14 Thread QuadCom

Actually an even easier trick would be to have 2 textareas that mirror
each others content. Hide one without the expandable. Show the other
with expandable. On the hide button, just do a reversal, show the
noexpandable, hide the expandable.

You can add a check on the submit of the form to delete the hidden
textarea so that it doesn't submit with the other form data.

On Feb 14, 2:11 pm, QuadCom supp...@quad-com.ca wrote:
 Here's my understanding.

 unbind will work for events. The expandable function you applied is
 not an event. What I would do in this instance is on the hide button,
 remove the textarea with the expandable and then insert a new textarea
 with the same id. That would appear to remove the expandable
 attributes.

 Don't forget, if there is text in the textarea, copy it to a var
 first, then do the remove/add step.

 You could write your own plugin to do all o that in one step ie.
 unexpandable

 On Feb 13, 3:39 pm, Rick Faircloth r...@whitestonemedia.com wrote:

  Nice try, but no prize yet...

  Given these scripts:

  $(document).ready(function() {
   $('#myTextarea').hide();

  });

  $(document).ready(function() {
   $('#hide').click(function() {
$('#myTextarea').unbind().slideUp();
return false;
   });

  });

  $(document).ready(function() {
   $('#show').click(function() {
$('#myTextarea').expandable().slideDown();
return false;
   });

  });

  and this HTML:

  div style=padding-left:100px;

   p[ strongNotes concerning textarea/strong ]
  [ notes ]
  [ a id=hide href=#hide/a ]
  [ a id=show href=#show/a ]
  [ export ]
  [ clear ]
   /p

   textarea id=myTextarea cols=100/textarea

  /div

  Why wouldn't your idea work, Josh?
  It makes sense to me.

  I can click #show and #myTextarea becomes .expandable and executes 
  .slideDown.
  But, when I then click #hide and #myTextarea starts to execute .slideUp,
  but then expands again, as it would if .expandable were still bound to it.

  Should I code this differently?

  Thanks,

  Rick

   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
   Behalf Of Josh Nathanson
   Sent: Friday, February 13, 2009 3:00 PM
   To: jquery-en@googlegroups.com
   Subject: [jQuery] Re: How to make an element *not* have a function 
   attached...

   This should work:

   $('#myTextarea').unbind(); // unbinds all handlers

   Then when you want to bind it again:

   $('#myTextarea').expandable();

   -- Josh

   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
   Behalf Of Rick Faircloth
   Sent: Friday, February 13, 2009 11:43 AM
   To: jquery-en@googlegroups.com
   Subject: [jQuery] Re: How to make an element *not* have a function
   attached...

   To answer your question, hopefully, the element, in this case a textarea,
   is set up like this:

   script

$(function() {
 $('#myTextarea').expandable();
  });

   /script

   ...and that's it.  It would be active as expandable all the time.

   So, there's no event, like click, etc., that triggers the function.

   However, I want to be able to click a link and disable the expandable
   functionality, until another link is clicked to re-enable the 
   functionality.

   In other words, having the textarea expandable is not something I want
   on all the time.

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
   Behalf Of Frederik Ring
Sent: Friday, February 13, 2009 2:04 PM
To: jQuery (English)
Subject: [jQuery] Re: How to make an element *not* have a function
   attached...

This should be done using $(this).unbind(event,function).
I don't know from your example how your handle the event so I cannot
give you a more specific answer.

On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Strange question, perhaps...but...

 If I have an element that has an function from a plug-in
 attached to it, such as:

 $(function() {
 $('#myTextarea').expandable();

 });

 How would I then be able to make #myTextarea not .expandable...

 $('#myTextarea').expandable('disable'); ...

 Is this something that can be controlled from the page code, or
 does something have to be built into the plug-in to allow this?

 Thanks,

 Rick


[jQuery] Re: How to make an element *not* have a function attached...

2009-02-14 Thread Rick Faircloth

Thanks for the tips!

Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of QuadCom
 Sent: Saturday, February 14, 2009 2:19 PM
 To: jQuery (English)
 Subject: [jQuery] Re: How to make an element *not* have a function attached...
 
 
 Actually an even easier trick would be to have 2 textareas that mirror
 each others content. Hide one without the expandable. Show the other
 with expandable. On the hide button, just do a reversal, show the
 noexpandable, hide the expandable.
 
 You can add a check on the submit of the form to delete the hidden
 textarea so that it doesn't submit with the other form data.
 
 On Feb 14, 2:11 pm, QuadCom supp...@quad-com.ca wrote:
  Here's my understanding.
 
  unbind will work for events. The expandable function you applied is
  not an event. What I would do in this instance is on the hide button,
  remove the textarea with the expandable and then insert a new textarea
  with the same id. That would appear to remove the expandable
  attributes.
 
  Don't forget, if there is text in the textarea, copy it to a var
  first, then do the remove/add step.
 
  You could write your own plugin to do all o that in one step ie.
  unexpandable
 
  On Feb 13, 3:39 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 
   Nice try, but no prize yet...
 
   Given these scripts:
 
   $(document).ready(function() {
$('#myTextarea').hide();
 
   });
 
   $(document).ready(function() {
$('#hide').click(function() {
 $('#myTextarea').unbind().slideUp();
 return false;
});
 
   });
 
   $(document).ready(function() {
$('#show').click(function() {
 $('#myTextarea').expandable().slideDown();
 return false;
});
 
   });
 
   and this HTML:
 
   div style=padding-left:100px;
 
p[ strongNotes concerning textarea/strong ]
   [ notes ]
   [ a id=hide href=#hide/a ]
   [ a id=show href=#show/a ]
   [ export ]
   [ clear ]
/p
 
textarea id=myTextarea cols=100/textarea
 
   /div
 
   Why wouldn't your idea work, Josh?
   It makes sense to me.
 
   I can click #show and #myTextarea becomes .expandable and executes 
   .slideDown.
   But, when I then click #hide and #myTextarea starts to execute .slideUp,
   but then expands again, as it would if .expandable were still bound to it.
 
   Should I code this differently?
 
   Thanks,
 
   Rick
 
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
Behalf Of Josh
Nathanson
Sent: Friday, February 13, 2009 3:00 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: How to make an element *not* have a function 
attached...
 
This should work:
 
$('#myTextarea').unbind(); // unbinds all handlers
 
Then when you want to bind it again:
 
$('#myTextarea').expandable();
 
-- Josh
 
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Rick Faircloth
Sent: Friday, February 13, 2009 11:43 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: How to make an element *not* have a function
attached...
 
To answer your question, hopefully, the element, in this case a 
textarea,
is set up like this:
 
script
 
 $(function() {
  $('#myTextarea').expandable();
   });
 
/script
 
...and that's it.  It would be active as expandable all the time.
 
So, there's no event, like click, etc., that triggers the function.
 
However, I want to be able to click a link and disable the expandable
functionality, until another link is clicked to re-enable the 
functionality.
 
In other words, having the textarea expandable is not something I want
on all the time.
 
 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] 
 On
Behalf Of Frederik Ring
 Sent: Friday, February 13, 2009 2:04 PM
 To: jQuery (English)
 Subject: [jQuery] Re: How to make an element *not* have a function
attached...
 
 This should be done using $(this).unbind(event,function).
 I don't know from your example how your handle the event so I cannot
 give you a more specific answer.
 
 On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  Strange question, perhaps...but...
 
  If I have an element that has an function from a plug-in
  attached to it, such as:
 
  $(function() {
  $('#myTextarea').expandable();
 
  });
 
  How would I then be able to make #myTextarea not .expandable...
 
  $('#myTextarea').expandable('disable'); ...
 
  Is this something that can be controlled from the page code, or
  does something have to be built into the plug-in to allow this?
 
  Thanks,
 
  Rick



[jQuery] Re: How to make an element *not* have a function attached...

2009-02-13 Thread Frederik Ring

This should be done using $(this).unbind(event,function).
I don't know from your example how your handle the event so I cannot
give you a more specific answer.

On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Strange question, perhaps...but...

 If I have an element that has an function from a plug-in
 attached to it, such as:

 $(function() {
         $('#myTextarea').expandable();

 });

 How would I then be able to make #myTextarea not .expandable...

 $('#myTextarea').expandable('disable'); ...

 Is this something that can be controlled from the page code, or
 does something have to be built into the plug-in to allow this?

 Thanks,

 Rick


[jQuery] Re: How to make an element *not* have a function attached...

2009-02-13 Thread Rick Faircloth

To answer your question, hopefully, the element, in this case a textarea,
is set up like this:

script

 $(function() {
  $('#myTextarea').expandable();
});

/script

...and that's it.  It would be active as expandable all the time.

So, there's no event, like click, etc., that triggers the function.

However, I want to be able to click a link and disable the expandable
functionality, until another link is clicked to re-enable the functionality.

In other words, having the textarea expandable is not something I want
on all the time.


 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Frederik Ring
 Sent: Friday, February 13, 2009 2:04 PM
 To: jQuery (English)
 Subject: [jQuery] Re: How to make an element *not* have a function attached...
 
 
 This should be done using $(this).unbind(event,function).
 I don't know from your example how your handle the event so I cannot
 give you a more specific answer.
 
 On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  Strange question, perhaps...but...
 
  If I have an element that has an function from a plug-in
  attached to it, such as:
 
  $(function() {
          $('#myTextarea').expandable();
 
  });
 
  How would I then be able to make #myTextarea not .expandable...
 
  $('#myTextarea').expandable('disable'); ...
 
  Is this something that can be controlled from the page code, or
  does something have to be built into the plug-in to allow this?
 
  Thanks,
 
  Rick



[jQuery] Re: How to make an element *not* have a function attached...

2009-02-13 Thread Frederik Ring

Ok, then you could do it like this:

script type=text/javascript

$(document).ready(function(){

$('#mytextarea').each(function(){
$(this).expandable();
});

$('#myButton').click(function(){
$('#mytextarea').unbind();
});

});

/script

Although I might think there is a more elegant way to do this? Hope it
helps though.

On Feb 13, 8:43 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 To answer your question, hopefully, the element, in this case a textarea,
 is set up like this:

 script

      $(function() {
           $('#myTextarea').expandable();
         });

 /script

 ...and that's it.  It would be active as expandable all the time.

 So, there's no event, like click, etc., that triggers the function.

 However, I want to be able to click a link and disable the expandable
 functionality, until another link is clicked to re-enable the functionality.

 In other words, having the textarea expandable is not something I want
 on all the time.

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Frederik Ring
  Sent: Friday, February 13, 2009 2:04 PM
  To: jQuery (English)
  Subject: [jQuery] Re: How to make an element *not* have a function 
  attached...

  This should be done using $(this).unbind(event,function).
  I don't know from your example how your handle the event so I cannot
  give you a more specific answer.

  On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
   Strange question, perhaps...but...

   If I have an element that has an function from a plug-in
   attached to it, such as:

   $(function() {
           $('#myTextarea').expandable();

   });

   How would I then be able to make #myTextarea not .expandable...

   $('#myTextarea').expandable('disable'); ...

   Is this something that can be controlled from the page code, or
   does something have to be built into the plug-in to allow this?

   Thanks,

   Rick


[jQuery] Re: How to make an element *not* have a function attached...

2009-02-13 Thread Josh Nathanson

This should work:

$('#myTextarea').unbind(); // unbinds all handlers

Then when you want to bind it again:

$('#myTextarea').expandable();

-- Josh


-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Rick Faircloth
Sent: Friday, February 13, 2009 11:43 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: How to make an element *not* have a function
attached...


To answer your question, hopefully, the element, in this case a textarea,
is set up like this:

script

 $(function() {
  $('#myTextarea').expandable();
});

/script

...and that's it.  It would be active as expandable all the time.

So, there's no event, like click, etc., that triggers the function.

However, I want to be able to click a link and disable the expandable
functionality, until another link is clicked to re-enable the functionality.

In other words, having the textarea expandable is not something I want
on all the time.


 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Frederik Ring
 Sent: Friday, February 13, 2009 2:04 PM
 To: jQuery (English)
 Subject: [jQuery] Re: How to make an element *not* have a function
attached...
 
 
 This should be done using $(this).unbind(event,function).
 I don't know from your example how your handle the event so I cannot
 give you a more specific answer.
 
 On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  Strange question, perhaps...but...
 
  If I have an element that has an function from a plug-in
  attached to it, such as:
 
  $(function() {
          $('#myTextarea').expandable();
 
  });
 
  How would I then be able to make #myTextarea not .expandable...
 
  $('#myTextarea').expandable('disable'); ...
 
  Is this something that can be controlled from the page code, or
  does something have to be built into the plug-in to allow this?
 
  Thanks,
 
  Rick



[jQuery] Re: How to make an element *not* have a function attached...

2009-02-13 Thread Rick Faircloth

Nice try, but no prize yet...

Given these scripts:

$(document).ready(function() {
 $('#myTextarea').hide();
});

$(document).ready(function() {
 $('#hide').click(function() {
  $('#myTextarea').unbind().slideUp();
  return false;
 });
});

$(document).ready(function() {
 $('#show').click(function() {
  $('#myTextarea').expandable().slideDown();
  return false;
 });
});

and this HTML:

div style=padding-left:100px;

 p[ strongNotes concerning textarea/strong ]
[ notes ]
[ a id=hide href=#hide/a ]
[ a id=show href=#show/a ]
[ export ]
[ clear ]
 /p

 textarea id=myTextarea cols=100/textarea

/div

Why wouldn't your idea work, Josh?
It makes sense to me.

I can click #show and #myTextarea becomes .expandable and executes .slideDown.
But, when I then click #hide and #myTextarea starts to execute .slideUp,
but then expands again, as it would if .expandable were still bound to it.

Should I code this differently?

Thanks,

Rick 



 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Josh Nathanson
 Sent: Friday, February 13, 2009 3:00 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: How to make an element *not* have a function attached...
 
 
 This should work:
 
 $('#myTextarea').unbind(); // unbinds all handlers
 
 Then when you want to bind it again:
 
 $('#myTextarea').expandable();
 
 -- Josh
 
 
 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
 Behalf Of Rick Faircloth
 Sent: Friday, February 13, 2009 11:43 AM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: How to make an element *not* have a function
 attached...
 
 
 To answer your question, hopefully, the element, in this case a textarea,
 is set up like this:
 
 script
 
  $(function() {
   $('#myTextarea').expandable();
   });
 
 /script
 
 ...and that's it.  It would be active as expandable all the time.
 
 So, there's no event, like click, etc., that triggers the function.
 
 However, I want to be able to click a link and disable the expandable
 functionality, until another link is clicked to re-enable the functionality.
 
 In other words, having the textarea expandable is not something I want
 on all the time.
 
 
  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
 Behalf Of Frederik Ring
  Sent: Friday, February 13, 2009 2:04 PM
  To: jQuery (English)
  Subject: [jQuery] Re: How to make an element *not* have a function
 attached...
 
 
  This should be done using $(this).unbind(event,function).
  I don't know from your example how your handle the event so I cannot
  give you a more specific answer.
 
  On Feb 13, 7:57 pm, Rick Faircloth r...@whitestonemedia.com wrote:
   Strange question, perhaps...but...
  
   If I have an element that has an function from a plug-in
   attached to it, such as:
  
   $(function() {
           $('#myTextarea').expandable();
  
   });
  
   How would I then be able to make #myTextarea not .expandable...
  
   $('#myTextarea').expandable('disable'); ...
  
   Is this something that can be controlled from the page code, or
   does something have to be built into the plug-in to allow this?
  
   Thanks,
  
   Rick