Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Oke Enyinna
jQuery datepicker does not work with aui:input field
October 27, 2011 4:59 AM
Answer

Oke Enyinna

Rank: Junior Member

Posts: 39

Join Date: April 14, 2010

Recent Posts

Hi,

I am trying to create a custom date field for a web content portlet. Among other things, I have added the following code to edit_article_content_xsd_el.jsp in a jsp hook:

<c:if test='<%= elType.equals("date") %>'>
<aui:input cssClass="lfr-input-text-container" label="" name="date" id="datepicker" size="10" type="text" value="<%= elContent %>" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#<portlet:namespace />datepicker").datepicker();
});
</script>
</c:if>

The line jQuery("#<portlet:namespace />datepicker").datepicker(); does not seem to work - the datepicker does not show when I click the input field. Am I doing something wrong?
Leo Pratlong
RE: jQuery datepicker does not work with aui:input field
October 27, 2011 5:49 AM
Answer

Leo Pratlong

Rank: Expert

Posts: 363

Join Date: July 6, 2010

Recent Posts

When you try it on Firebug (or in browser debugger), is there any error?

One more thing: you should better use
1Liferay.on('allPortletsReady', function() {


instead of

1jQuery(document).ready(function(){
Oke Enyinna
RE: jQuery datepicker does not work with aui:input field
October 27, 2011 6:55 AM
Answer

Oke Enyinna

Rank: Junior Member

Posts: 39

Join Date: April 14, 2010

Recent Posts

Thanks for the help. Yes, there is an error, the jquery object jQuery("#<portlet:namespace />datepicker") is undefined. That's strange because I can see it when I view source.
Leo Pratlong
RE: jQuery datepicker does not work with aui:input field
October 27, 2011 7:53 AM
Answer

Leo Pratlong

Rank: Expert

Posts: 363

Join Date: July 6, 2010

Recent Posts

Yes but I think that <portlet:namespace /> should not be interpreted in your JSP file (or its value is wrong). Firebug tells you "jQuery("#<portlet:namespace />datepicker") is undefined" which means that the browser try to find a tag with the ID "<portlet:namespace />datepicker" instead of a tag with the ID (for example) "p30_datepicker".
I can't try right now the code to tell you the solution, but you have to work the <portlet:namespace/> to find why it's not interpreted.
Laxman Rana
RE: jQuery datepicker does not work with aui:input field
March 22, 2012 3:15 AM
Answer

Laxman Rana

Rank: Junior Member

Posts: 42

Join Date: February 29, 2012

Recent Posts

@OKE...

i have done this thing through this code....

<link type="text/css" href="/css/jquery-ui-1.8.15.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.15.custom.min.js"></script>

<aui:input name="startDate" id="basics" />
<script type="text/javascript">
jQuery(document).ready(
function() {
jQuery('#<portlet:namespace />basics').datepicker();
}
);
</script>
Oke Enyinna
RE: jQuery datepicker does not work with aui:input field
March 22, 2012 6:51 AM
Answer

Oke Enyinna

Rank: Junior Member

Posts: 39

Join Date: April 14, 2010

Recent Posts

Thanks. I think this is more or less how I got it to work.
Laxman Rana
RE: jQuery datepicker does not work with aui:input field
March 22, 2012 7:23 AM
Answer

Laxman Rana

Rank: Junior Member

Posts: 42

Join Date: February 29, 2012

Recent Posts

tell me if wont be able to do it....