Side navigation
#6692 closed enhancement (fixed)
Opened June 18, 2010 03:08PM UTC
Closed September 22, 2010 03:53PM UTC
.data(object) should extend the current settings not replace them.
Reported by: | ashays | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.3 | |
Component: | data | Version: | 1.4.2 |
Keywords: | data | Cc: | |
Blocked by: | Blocking: |
Description
Unless there's some logical reason as to why this can't happen, I think it would be best if calling $(selector).data(object) would extend the current set of data. That is, if I were to say:
var data = {a:1, b:2, d:3};
$("#id").data("a", "apple")
.data("b", "banana")
.data("c", "codfish")
.data(data)
.data();
The return would be {a:1, b:2, c: "codfish", d:3};
Agreed. That would also solve the problem of accidentally clobbering some other plugin's data -- unless you used the same name, of course.