question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to add a new plugin for only one filter but it is applied for all the filters seems.

See original GitHub issue

Hi

I want to show a custom calendar for filter of type ‘date’, on clicking on the input field provided (same way as it is being done in the widget demo by using bootstrap-datepicker). For that I have created a new plugin in my code. The code is as given below

      // Adding new plugin 'showCalender'

       $.fn.queryBuilder.define('showCalender', function(opt)
       {
           this.on("click", this.showCal);
       });

       /**
        * Adding new function to show calender on click
        */
       $.fn.queryBuilder.extend({
           showCal : function(element)
           {
               if($(element.target).attr("class") === "form-control" && $(element.target).attr("type") === "text" )
               {
                   //Do stuff here to show the calender
               }
           }
       }); builder.queryBuilder({
           sortable: true,
           plugins:
           {
               'showCalender': true // 
           },
           filters:
           [       
               {
                   id: 'ona',
                   label: 'Org Name',
                   type: 'string'
               },
               {
                   id : 'ca',
                   label : 'Created at',
                   type : 'date' //I want to initialize for this filter
               }
           ]
       });

When I am clicking on input field for id: ‘ona’ filter, then also it is showing the calender. I have tried “plugin : showCalender” but it did not work and throws some error. I guess the error is because plugin is not jQuery plugin. So Is there any way to initialize the plugin ‘showCalender’ for only 2nd filter?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mistic100commented, Feb 18, 2016

(edited your message with valid markdown for code blocks)

So you found the problem: you need a jQuery plugin, not a QueryBuilder plugin.

It’s as simple as :

$.fn.showCalender = function(options) {
    // Do stuff here to show the calender
    // "this" is your element, the rule input
    // "options" is the filter's "plugin_options"

    return this;
};

Do not forget to do this.trigger('change') after changing the input value, otherwise the builder will not refresh it’s model.

0reactions
shrabaneecommented, Feb 18, 2016

Okay. Thanks again @mistic100

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filters not working | WordPress.org
The filter in the Media Library doesn't seem to work. On grid view, selecting a term seems to refresh the view, but it's...
Read more >
JetSmartFilters Not Working: 7 Things You Need to Check
In this troubleshooting article, you will find solutions to the 7 most common issues why JetSmartFilters may not be working.
Read more >
Include filtering attributes with plug-in registration - Power Apps
Filtering attributes are a list of entity attributes that, when changed, cause the plug-in to execute. These attributes can be set when ......
Read more >
Product Filters - WooCommerce
Installation · Purchase the product from WooCommerce.com · Download the ZIP file from your WooCommerce.com dashboard · Go to Plugins > Add New...
Read more >
Use filters in Adobe Photoshop
To apply filters cumulatively, click the New Effect Layer icon , and choose an additional filter to apply. Repeat this procedure to add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found