I am looping through a hash using the .each method and then insert a
new element into my page using values from the hash. I added a check
to make sure I am not inserting the same element multiple times, but
it seems to fail. Any ideas?
items.each(function(item) {
var pid = item['pid'];
var stuff = item['stuff'];
if( !$(pid) ) { // if DOM element with that id already exists, do
not proceed <-- this seems to fail
new Insertion.Top('body', '<div id="'+pid+'">'+stuff+'</
div>' );
}
});
So in this case, in my hash I have
{"pid":"142636","stuff":"some html"},
{"pid":"142636","stuff":"some more html"}
and I want to only insert the first element, not both. But for some
reason it inserts both
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---