cancel
Showing results for 
Search instead for 
Did you mean: 

Create button 'Clear' in Advantage Search Form

wns
Confirmed Champ
Confirmed Champ
Hello,

The target is having a button to clear a form. Concretely, in the Advantage Search. At the moment, I can show the button in the web page. I'm describing the stepts to get this:

1.- Add two buttons: Add the following code into the file "advsearch_noiframe.get.html.ftl" located in "config/alfresco/web-extension/site-webscripts/org/alfresco/components/search/":
 

     <div class="yui-u align-right">
         <span id="${el}-clear-button-1" class="yui-button yui-push-button clear-icon">
            <span class="first-child">
               <button type="button">${msg('button.clear')}</button>
            </span>
         </span>
      </div>

     <div class="yui-u align-right">
         <span id="${el}-clear-button-2" class="yui-button yui-push-button clear-icon">
            <span class="first-child">
               <button type="button">${msg('button.clear')}</button>
            </span>
         </span>
      </div>



2.- Set the style: Add the following code into the file "search.css" placed in "..\resources\components\search\":



    .search .clear-icon span.first-child
     {
       background: url(../images/delete-tag-off.png) no-repeat 12px 4px;
       padding-left: 24px;
      }



3.- Add the control on the buttons: I added the following code into the files "advsearch_noiframe.js" and "advsearch_noiframe-min.js" located in "\resources\components\search\" but it doesn't work:


    …
        this.widgets.clearButton1 = Alfresco.util.createYUIButton(this, "clear-button-1", this.onClearClick);
        this.widgets.clearButton2 = Alfresco.util.createYUIButton(this, "clear-button-2", this.onClearClick);
   …


The step 3 doesn't work. Furthermore, I tried to call the existing function "onSearchClick" through one of the new created button but it doesn't work.

I supose that the next step 4 it would be to create the function "onClearClick" into the file "advsearch_noiframe.js" but first of all the step 3 have to work.

Do you know if I'm doing it well or if I forgot some steps?

Thanks you very much for your help.
1 REPLY 1

wns
Confirmed Champ
Confirmed Champ
Hi all,

the solution for the step 4 is:

4- Add the function calls "onClearClick" into the files "advsearch_noiframe.js" and "advsearch_noiframe-min.js" located in "\resources\components\search\":


    …
          onClearClick: function ADVSearch_onClearClick(e, obj)
      {
         document.getElementById(this.currentForm.runtime.formId).reset();
         document.getElementById(this.id + "-search-text").value = "";
      }

    …



That's all.

Bye bye