Reload a pocketquery macro with javascript

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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

66 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you