Ticket #10784 (closed bug: invalid)
$.removeData is not working in 1.7
| Reported by: | istvan.m.antal | Owned by: | istvan.m.antal |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
As of 1.7, removeData is not working, here is a simple test case: http://jsfiddle.net/gGvHT/
After the second click, the alert should not show "test", but it still does, in other words, the data is not getting removed.
Change History
comment:1 Changed 18 months ago by dmethvin
- Owner set to istvan.m.antal
- Status changed from new to pending
comment:2 Changed 18 months ago by trac-o-bot
- Status changed from pending to closed
- Resolution set to invalid
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Did you expect .removeData to remove the data attribute from the HTML? That's not how it works. The data APIs only remove the data from the internal object. When you ask for the data the next time, it finds a match in the data- attribute on the element.
The docs clearly mention this:
More information is here:
http://www.learningjquery.com/2011/09/using-jquerys-data-apis
In general, if you are not interested in the performance benefit of having the data cached by jQuery, skip the .data() API altogether and work directly with .attr() on the attribute.