I know there is a Hash() object in the Javascript prototype framework, but is there anything in Jquery like this?
As I would like to stick with one javascript framework, rather than mixing the Prototype Frame work and the JQuery framework and use at the same time, as I worry there will be conflict and create side-effects.
So my question is: how to create Hash object/array using jquery?
Here is my function:
/* prototype framework, I want to change this to jQuery! */
var starSaves = new Hash();
function myHover(id, pos)
{
var starStrip = $('star_strip_' + id);
if (starSaves.keys().indexOf(id) == -1)
{
var starSave = new Array();
var imgs = starStrip.select("img")
alert(imgs);
for (var i = 0; i < imgs.length; i++)
{
starSave[starSave.length] = imgs[i].src;
if (i < pos)
imgs[i].src = "/images/star_1.gif";
else
imgs[i].src = "/images/star_0.gif";
}
starSaves.set(id, starSave);
}
}
A basic
Hash
can be achieved with basic JavaScript, not jQuery (I know that Prototype's Hash adds extra functionality, but you don't use it here).There's a standalone hash table implementation called jshashtable (full disclosure: I wrote it). Using it, your code would be:
I think you don't need jQuery for this.
There is no prototype Hash equivalent in jQuery that I know of.
Could the following be of any use to you? using jQuery
Glancing at the jQuery documentation I'm not seeing anything that specifically for this. But you can easily do this with just a regular javascript object: