title: javascript calling a function with params on window object
body: <p>So I'm trying to call this method:</p>
  
  <blockquote>
    <p>refreshMoradaLabel = function(idPlaceHolder) {...};</p>
  </blockquote>
  
  <p>With the window object:</p>
  
  <blockquote>
    <p>window [ refreshMoradaLabel('id') ] ();</p>
  </blockquote>
  
  <p>But this doesn't seem to work. It's only when the method has no parameters.
  Is there a way to work using the <code>window [ variable ] ()</code> syntax?</p>
  
  <p>Edit;</p>
  
  <p>ok here's the code:</p>
  
  <p>moarada.jsp has the code with these methods:</p>
  
  <pre><code>&lt;c:set var="methodOnClose" value="refreshDynamicValues" /&gt;
  &lt;c:if test="${empty fieldInstance || (not empty fieldInstance &amp;&amp; isTramitacao)}"&gt;
    &lt;c:set var="methodOnClose" value="refreshMoradaLabel(${dfieldId})" /&gt;
  &lt;/c:if&gt;
  &lt;a class="texto" href="#" onclick="editMoradaPopup('${dfieldId}','${methodOnClose}');" id="moradas_${dfieldId}"&gt;&lt;img alt="${moradaDes}" src="${pageContext.request.contextPath}/images/icon/icon-pesquisa.png"&gt;&lt;/a&gt;
  </code></pre>
  
  <blockquote>
    <p>window.refreshMoradaLabel = function(idPlaceHolder) {</p>
  </blockquote>
  
  <pre><code>    alert("label:" +idPlaceHolder);
      if($F(idPlaceHolder) != '') {
          //Update label
          new Ajax.Updater(idPlaceHolder+'_label', 'moradaPopupLocaleAware.do2?method=getLabel', 
                  {method: 'get', parameters: 'id='+$F(idPlaceHolder)});
      }
  
  };
  </code></pre>
  
  <blockquote>
    <p>window.editMoradaPopup= function(idPlaceHolder,method){
        alert(idPlaceHolder);
    Ext.onReady(function(){
    action = "${pageContext.request.contextPath}/moradaPopupLocaleAware.do2"; 
    action += "?method=edit&amp;id="+$(idPlaceHolder).value;</p>
  </blockquote>
  
  <pre><code>        action += "&amp;idPlaceHolder="+idPlaceHolder;
          action += "&amp;savemorada=true";
          action += "&amp;window=winchoose";      
          return ExtWindowAll('${moradaDes}',action,'','html',true,true,true,650,400,true,true,'fit', method);
      });
  
  };
  </code></pre>
  
  <p>The method ExtWindowAll eventually call code from another js file, that results calling a close window event, with the string of the method name(refreshMoaraLabel) including possible params:</p>
  
  <blockquote>
    <p>winchoose.on('close', function( p ) {
            if(functionOnClose) {<br>
                alert("method: "+functionOnClose);
                var substr=functionOnClose.match(/(([^)]*))/);
                var param='';
                if(substr!=null){
                  param=substr[1];
                  param="'"+param+"'";
                }</p>
  </blockquote>
  
  <pre><code>        debugger;
          if(window[functionOnClose]) {
              window[functionOnClose](param);
          }
      }
  });
  </code></pre>