Search code examples
liferayliferay-6

Refresh portlet when it's dropped/moved


How would one go about refreshing a portlet, after it finishes moving (dropped unto final location).

I have been trying to call a JS function on a certain event, but I've been unable to bind it uniquely to a specific portlet instance (code below). Is there anything I'm missing/different strategy.

Liferay.on('initLayout', function(event) {
    Liferay.once(function() {
        Liferay.Layout.on('drag:end', function(event) {
            refreshme(event);
        }, Liferay.Layout, 'bindDragDropListeners');
    });
});

Liferay 6.2


Solution

  • Well, figured a solution to it, so might as well post in case someone has a similar request.

    Liferay.on('initLayout', function(event) {
      Liferay.once(function() {
        Liferay.Layout.on('drag:end', function(event) {
         var userDrag = A.one('.yui3-dd-dragging');
         var refreshCall = "#p_p_id_"+userDrag.portletId+"_";
         Liferay.Portlet.refresh(refreshCall);
      }, Liferay.Layout, 'bindDragDropListeners');
    });
    

    This can, obviously, be tuned, but it's functional.