#1092 closed feature (wontfix)
ToggleText function requested
Reported by: | frontier | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1.4 |
Component: | core | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
There are lots of other useful toggle functions in JQuery, I think one for Text is needed also. Thanks :)
Change History (7)
comment:1 Changed 16 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Type: | enhancement → feature |
comment:2 Changed 16 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
how do I use that? sorry I'm not a JS guru
comment:3 Changed 16 years ago by
Component: | ajax → core |
---|---|
Milestone: | 1.1.3 → 1.1.4 |
Resolution: | → wontfix |
Status: | reopened → closed |
Version: | 1.1.2 → 1.1.3 |
You would include that in your page, then you would call it like so:
$("#myelem").textToggle();
comment:4 Changed 16 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
The solution posted only works once, since the variable is defined on DocumentReady. This is unacceptable, as toggle(Function even, Function odd) will toggle functions ad infinitum. Unfortunately, the following does not work:
$(.class).click(function() { $(.class).toggle(function() { $(this).text('to');}, function() { $(this).text('fro');} ); });
This is what I assume the OP is trying to accomplish, as I am trying to accomplish the same.
Example usage is toggling of an element with a text-based link, having text switch between "open" and "close", "show" and "hide", etc.
comment:5 Changed 15 years ago by
jQuery.fn.toggleText = function(a, b) { return this.each(function() { jQuery(this).text(jQuery(this).text() == a ? b : a); }); };
comment:6 Changed 13 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
We're not looking to land this at the time being.
comment:7 Changed 12 years ago by
I just encountered a situation where such a function being in the jQuery core would have been a lifesaver and saved a whole lot of extra code / writing a plugin.
Think of the following scenario:
You have a container div and inside you have a header and a body div. The sole purpose is to allow you to toggle the body sections visibility (collapsible sections).
What happens when you want to show and hide a section and want a link within the header to change accordingly? Show more and Show less for example? You have to write the above code in, jQuery should have this by default.
Please consider adding this.
I'm not entirely sure what you're requesting, specifically - but this sounds like something that could be easily duplicated otherwise.