Reload a pocketquery macro with javascript

Cuto Calleja
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2016

I use a macro as a filtering basis to be applied o others in a page. All the macros in the page with the only exception of this one are with the option "dynamic load"... I need to refresh this macro by the way of a button calling a function in javascript trying to execute the following code including new parametters (being HD_J_FILTERS the name of my query:

 

function relodafilter(recarga)

{

        var newParameters = {ISDTI: jQuery('#select-isdti').val(),Type: jQuery('#select-type').val(),Status: jQuery('#select-status').val(),Area: jQuery('#select-area').val(),Priorite: jQuery('#select-priorite').val(),Root: jQuery('#select-root').val(),Department: jQuery('#select-department').val(),OrgName: jQuery('#select-orgname').val(),GroupName: jQuery('#select-groupname').val(),Impact: jQuery('#select-impact').val(),Uno: recarga};

        jQuery('#my-pocketquery-form select').change(function() {

    var selectedValue = jQuery(this).val();

    jQuery('.pocketquery-dynamic-load[data-query="HD_J_FILTERS"]').each(function() {

        var container = jQuery(this);

        var dataIndex = container.data('index');

        var data = PocketQuery.getDynamicLoadData(dataIndex);

        data.queryParameters = newParameters;

        PocketQuery.load({

            container: container,

            data: data

        });

    });

});

}

But... anything is "refreshed"... I am missing something? Should maybe change the parametter "dynamicload" somewhere to let it work? I've tried many other options without success!!!

Thanks in advance!

 

1 answer

0 votes
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2016

Hi Cuto!

Let's try to break down this a little. Can you please use your browser's developer tools console and run the reload for a secific container? Something like this:

(function() {
	// get the first container for the query HD_J_FILTERS
	var $container = jQuery('.pocketquery-dynamic-load[data-query="HD_J_FILTERS"]').eq(0);
	var dataIndex = $container.data('index');
	var data = PocketQuery.getDynamicLoadData(dataIndex);
	data.queryParameters = ...your new parameter object...
    PocketQuery.load({
        container: $container,
        data: data
    });
}());

If that doesn't work, we can check on where the problem comes from.

Regards, Felix

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events