# Jquery / JS problem with adding clicks for object in list

**URL:** https://forum.kirupa.com/t/jquery-js-problem-with-adding-clicks-for-object-in-list/325773
**Category:** Uncategorized
**Created:** [November 3, 2011, 4:52pm UTC](https://forum.kirupa.com/t/jquery-js-problem-with-adding-clicks-for-object-in-list/325773 "2011-11-03T16:52:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Freeseus](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@Freeseus](https://forum.kirupa.com/u/Freeseus)
#### Post date: [November 3, 2011, 4:52pm UTC](https://forum.kirupa.com/t/jquery-js-problem-with-adding-clicks-for-object-in-list/325773/1 "2011-11-03T16:52:30Z")

</div>

I don’t have a working example of this, so I’m sorry I can’t redirect you to a url. I think this is a fairly easy to solve issue… at least I hope.

I’m trying to change/update something someone else did.

ABC.StoryTools.ShareThis.prototype.render = function() {  
var self = this;  
var ul = $(’#shareListOverlay’).find(‘ul’).empty();  
var href, li, item;  
var title = document.title.replace(/ - ABC company$/, ‘’);  
var list = ABC.storyTools.shareList;

```
var section = siteMapTerm ? siteMapTerm.replace('Sections.','') : ""; 
var relatedAccts = self.getTwitterList(section);
var summary = ABC.storyTools.storySummary ? ABC.storyTools.storySummary.substring(0 , 255) : "";
var originalUrl = document.URL;
var canonicalUrl = $('link[rel=canonical]').attr('href');
if(!canonicalUrl){
    canonicalUrl = originalUrl;
}

for(var i=0; i&lt;list.length; i++) {
item = list*;

href = item.link.replace('{url}', escape(canonicalUrl)).replace('{title}', encodeURIComponent(title))
        .replace('{section}', encodeURIComponent(section))
        .replace('{summary}', summary)
        .replace('{source}', 'Financial Times')
        .replace('{canonicalurl}', escape(canonicalUrl))
        .replace('{originalUrl}', escape(originalUrl))
        .replace('{relatedAccts}', encodeURIComponent(relatedAccts));
    
li = $('&lt;li/&gt;').addClass(item.id);

    if(item.css) {
        li.attr('style', item.css);
    }

    $('&lt;a/&gt;').text(item.label).attr('href', function(){
newwindow=window.open(href, '', 'height=400,width=500');}).attr('si:link', 'social-media_' + item.id).appendTo(li);
    
    
    li.appendTo(ul);
    
}    

```

};

I click a “share this” button and it launches an overlay with a bunch of buttons from ‘list.’ What’s happening is that after clicking the “share this” button, it launches a popup for each button in the list. I want to launch a popup only when you click a button from the list.

Ideas?
