留言板

How to replace action attribute value through jquery/aui:script???

thumbnail
Arunjyoti Banik,修改在9 年前。

How to replace action attribute value through jquery/aui:script???

Junior Member 帖子: 74 加入日期: 14-8-26 最近的帖子
Consider this code piece::

<portlet:actionURL name="activate" var="activateUrl">
<portlet:param name="PaGeName" value="activate-jsp"></portlet:param>
</portlet:actionURL>

<portlet:actionURL name="deactivate" var="deactivateUrl">
<portlet:param name="pagename" value="deactivate-jsp"></portlet:param>
</portlet:actionURL>

/* A menubar */
<ul>
<li>
<a onclick="submitform()">Activate User</a>
</li>
<li>
<a onclick="submitForm()">Deactivate User</a>
</li>
</ul>
<aui:form cssClass="selName">
<% \\some code here\\
for (int i=0; i < displayList.size(); i++)
{
User users = (User)displayList.get(i);
ResultRow row = new ResultRow(users, users.getUserId(), i);
%>
<table>
<tbody>
<td><aui:input name="radio" type="radio"/></td>
\\ some <td>s here;
<% } %>
</tbody>
<liferay-ui:search-iterator paginate="true" searchContainer="<%= searchContainer %>" />
</table>
</aui:form>

I have written a jQuery function like this::

<script>
function submitform()
{
alert("Do You Want To Activate The Selected User??");
$('.selName').attr("action", "<%= activateUrl%>");
$('.selName').submit();
}

function submitForm()
{
alert("Do You Want To Deactivate The Selected User??");
$('.selName').attr("action", "<%= deactivateUrl%>");
$('.selName').submit();
}

</script>

Although the alertboxes are displaying perfectly on click event, the form is not getting submitted. But if I just place my radio button inside another form and give either of the actionUrls, the form submit is happening. Problem is, then I can select multiple radio buttons even I've given same name and page navigation will happen to the link of the given actionUrl. Please help, cant figure out where and what is wrong. I want like this because I have to send data to another page through eventing.

Thanks in Advance
Arun
thumbnail
David H Nebinger,修改在9 年前。

RE: How to replace action attribute value through jquery/aui:script???

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
have you tried the obvious?

* use chrome to inspect the elements to check out the elements, their classes, etc? Verify that there is a form name with "selName" class?
* use chrome to set a breakpoint on the alerts to determine what jquery is actually finding and doing?
thumbnail
Arunjyoti Banik,修改在9 年前。

RE: How to replace action attribute value through jquery/aui:script???

Junior Member 帖子: 74 加入日期: 14-8-26 最近的帖子
Hello David,

I was using firefox from the beginning, so haven't checked in chrome. I will definitely do it now.
Secondly I want to inform, that the same code is not giving error in maven build but in ant build I am getting an error of Javascript minifier failed ........... at the line where I am adding value of <%= activateUrl%> or <%=deactivateUrl%> to the action attribute of the form. In firefox I debugged that it is failing to add a ')' after http:// since the value is translated to the page link.

Arun
thumbnail
Arunjyoti Banik,修改在9 年前。

RE: How to replace action attribute value through jquery/aui:script???

Junior Member 帖子: 74 加入日期: 14-8-26 最近的帖子
Hello David,

I resolved my problem. I did it using the same code-piece but replaced the cssClass with id.

However, I cant figure out why the same code-piece is failing for cssClass but working for the id.

But it solved my problem.

Arun