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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

849 views 2 9
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