I don't understand the architecture of this app well enough to know what this code does or even how to test it.  I notice that you use a parseInt() here on dataset.index, but below you don't use parseInt().