function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VivoVivo 

Getting dialog box to re-render

Hi,

 

I am using the Jquery dialog box on one of my pages that pulls up a list of custom objects from the database. I am trying to incorporate a search inside of that dialog box with an input text which is working oddly right now. Once I put in the search parameters and hit search, I have the dialog box close, and rerender and then open again so that the list it pulls up will be updated. However, it is not updating the list. If I close the dialog box and rerender the whole page with another button and pull it up again, then the list IS updated. I am unsure what to do to get the correct functionality.

 

Steps:

1) User opens dialog box

2) User types in search parameter and hits 'Search'

3) Javascript closes the dialog box

     Javascript pulls the parameter value and constructs a query. Then it calls actionfunction "searcherd" and passes the query along.

4) Actionfunction searcherd calls apex method searcherf that updates the list (Actionfunction also rerenders everything)

5) Javascript opens the dialog box

 

 

Does anyone know how to make this function correctly?

 

This is my dialog box:

<div id="dialog" title="Add Functions">
<apex:form >
  

  <button id="Add">Add</button>
  <apex:outputText > {!db} </apex:outputText>
    <input type="text" id="SearchName"/>
     <button id="searchfu">search</button>
    
 <table id="addfuncs" class="func">     
 <tr>
<th>Function Name</th>
<th>Function Type</th>
<th>Description</th>
<th>Parameters</th>

</tr>
<tbody>

<apex:repeat id="allfunctionslist" value="{!AllFunctions}" var="f">
    <tr id="{!f.id}">
      
        <td style="text-align:center;" >
      {!f.name}  
      </td>
   
      <td>
      {!f.Function_Type__r.name}  
      </td>
      
       <td > {!f.Description__c}  </td>
       
       <td >
       <apex:repeat value="{!f.TEST_PARAMETERS__r}" var="p">
       {!p.name} ( {!p.Type__c} ) <br/>
       </apex:repeat>
       </td>
      
</tr>

  </apex:repeat>    
</tbody>
  
</table>


</apex:form>
    </div>

 

This is the function that runs when the search button is clicked:

$(function() {
    $( "#searchfu" )
      .button()
      .click(function( event ) {   
               $( "#dialog" ).dialog( "close" );
          var x = 'Select name,id,description__c,Function_Type__r.name,(select name,id,Default_Value__c,Type__c,Description__c from TEST_PARAMETERS__r) FROM Function__c WHERE name LIKE \''+document.getElementById("SearchName").value+'%\' order by name';

            searcherd(x); 
          
              $( "#dialog" ).dialog( "open" );
          
       
      });
  });

 

This is the actionfunction called by the javascript&colon;

 

  <apex:actionFunction name="searcherd" action="{!searcherf}" rerender="dialog,addfuncs">
        <apex:param name="qry" value="" />
        </apex:actionFunction>

 

 

 

 

 

This is the function on the apex-side that gets called to update the list

 public void searcherf(){
  
    n = ApexPages.currentPage().getParameters().get('qry');
   
      
       
    AllFunctions=Database.query(n);
   
    }

 

Avidev9Avidev9

Well the problem lies here 

 

apex:actionFunction name="searcherd" action="{!searcherf}" rerender="dialog,addfuncs">

 You can only rerender apex element where as dialog and addfuncs are Id of HTML tags. Try wrapping the dialog with a outputPanel, give it a Id say "dialogPanel" and rerender the same from action function. Do this for addfuncs as well.

 

 

 

 

 

VivoVivo

Hi,

 

I tried doing as you suggested and here is what seems to be happening. The rerender works but it rerenders the outputpanel (Along with the table) to the bottom of the current page with the correct results and then opens the dialog box witht he same contents it had before (without rerendering it).

 

I tried doing it so that I don't close the dialog box, rerender, and open it again, but the same thing occurs.

I've been reading that JQuery's dialog box function acts in a way that no matter where it is placed in the code, it is added to the end of the page after the form tags, perhaps that has something to do with this weird error?

 

What should I do to proceed?

 

 

VivoVivo

I ended up solving this by just creating a new page that gets opened up as a popupwindow instead. Although using the dialog box would have been nice, I couldn't find any solutions to making it rerender correctly.