Question

i use Liferay 6.1, I created a portlet with code (Link: http://www.liferay.com/community/wiki/-/wiki/Main/Using+Lifery+provided+Color+Picker+in+Own+Portlets)

<script type="text/javascript"> jQuery( function() { var colorPicker = new Liferay.ColorPicker( { hasImage: true } ); } ); </script>


<tr> <td> <input class="text-input" id="color" name="color" size="9" type="text" value="" />

<img align="absmiddle" alt="<liferay-ui:message key="color" />" border="0" class="use-color-picker" height="18" hspace="0" src="<%= themeDisplay.getPathThemeImages() %>/color.png" title="<liferay-ui:message key="color" />" vspace="0" width="18" style="cursor: pointer;" />

</input> </td> </tr>

but it doesn't work, please help me :)

Était-ce utile?

La solution

You need to pass more options to new Liferay.ColorPicker . According to the guide you posted:

Options:

•context (Object): A DOM object which specifies the context in which to search for the item
•hasImage: (Boolean) If set to true, it uses the "item" param or whatever image has the .use-color-picker class as the image
•item: (Object|String): A DOM object or a jQuery Selector string that specifies which field to insert the selected value into
•onChange (Function): A function that will get called whenever the color changes
•onClose (Function): A function that will get called when the color picker is closed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top