Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Bill Corley
Calling Dynamically
October 31, 2012 3:24 PM

Bill Corley

Rank: New Member

Posts: 7

Join Date: October 26, 2012

Recent Posts

I have a simple portlet with a single text input box and an empty DIV under it to display the results from a query that is based on what was typed in the text field. The query is handled in AUI with the call from either the onSubmit or the text field onChange. This works perfectly when I type something in the text field and click outside the field or press enter or click the submit button. No problem.

In some cases the result is unique and all is fine. But in other cases the result is not unique. In this not unique case I am trying to have a part of each result linked so that clicking the link will run this AJAX call again with a value that will bring back that unique record. I easily can get the value into the form's text field. And once the value is in the text box pressing enter or clicking submit does bring back the record correctly. But everything I have tried to get it to submit again automatically is not working as expected. Either it brings up the portlet in a page all by itself or I can't get a handle on calling the AUI code.

Here is the basis of the code I'm using. How do I get an Anchor onChange="" from the first result to find and call the on form's 'submit'. code again? What should that onClick Javascript look like?

 2    id="<portlet:namespace />fm" method="post"
 3    name="<portlet:namespace />fm" >
 5    <table class="lfr-table callup-search">
 6        <tr>
 7            <td class="callup-search-spacer"></td>
 8            <td class="callup-search-input"><input
 9                name="<portlet:namespace />uid" id="<portlet:namespace />uid" size="25" type="text"
10                value="<%=uid%>" /></td>
11            <td class="callup-search-button">
12                <input name="submit" type="image" src="/callup-portlet/images/btn-go.gif" alt="Go" />
13                <!-- input type="submit" value="<liferay-ui:message key="Go" />" / -->
14            </td>
15            <td class="callup-search-spacer"></td>
16        </tr>
17    </table>
19<div id="result"></div>
22<aui:script use="aui-io-request,aui-parse-content">
23    var form ='#<portlet:namespace />fm');
24    var parentNode = form.get('parentNode');
26    parentNode.plug(A.Plugin.ParseContent);
28    form.on(
29        'submit',
30        function(event) {
31            var uri = '/people-search-portlet/search.jsp';
33            var myAjax =
34                uri,
35                {
36                    form: {
37                        id: form
38                    },
39                    on: {
40                        success: function(event, id, obj) {
41                                                       document.getElementById("result").innerHTML= this.get('responseData');            
42                        }
43                    }
44                }
45            );
46            event.halt();
47        }
48    );