1

I'm storing data with this code.

baslat: function(data) {
            var $bu = $(this).get(0);
            if(!$.data($bu, "ipucu_secenekleri")){
                metodlar.domEkle.apply(this, data);
                var ipucu_secenekleri = $.extend({}, s, data);

                $.data($bu, 'ipucu_secenekleri', ipucu_secenekleri);

            }

            return this;
        },

But when I try to get the data named ipucu_secenekleri

            domEkle: function (data) {

               var $bu = $(this).get(0),
               icerik = $.data($bu,"ipucu_secenekleri");
               console.log(icerik) //undefined
            }

Thats more... These are undefined too:

$.data($bu).ipucu_secenekleri

var datam = $.data($bu);
datam.ipucu_secenekleri;

But here is the funny part. When I try to get the whole data and console it I can see the data that I stored...

$.data($bu); //it returns the data object which contains ipucu_secenekleri.

But as you can see asigning to a variable is useless. I cannot reach the sub levels nor for in loop can.

for(var i in datam){console.log(datam[i])} //no effect
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Lupus
  • 1,519
  • 3
  • 21
  • 38

1 Answers1

0

$.data() is a low-level method. You should try the .data() method :

In your code replace

$.data($bu, "ipucu_secenekleri")

with

$bu.data("ipucu_secenekleri")

...and so on.

Thomas Guillory
  • 5,719
  • 3
  • 24
  • 47