Home Forums Porto Admin Template Dropdown button in sidebar widget

This topic contains 2 replies, has 2 voices, and was last updated by  stesvis 1 day, 5 hours ago. This post has been viewed 42 times

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10025526

    stesvis
    Participant

    Hi,

    I am wondering why a dropdown button would not work (click doesn’t open the dropdown) when I place it in the right sidebar widget.

    The same button works fine in the page content.

    Also, jQuery doesn’t seem to work in the widget either.
    I placed a bootstrap button there too, with a js-click-me class and this script, but the alert won’t fire.

    $(document).on('click', '.js-click-me', function (e) {
                    alert('hello');
                });

    Is there a solution?

    http://dusano.levitica.ca/Test/test3

    Screenshot: https://snag.gy/uWe6Xf.jpg


    • This topic was modified 1 week, 1 day ago by  stesvis.
    #10025540

    Support2
    Keymaster

    Hello Stevis,

    Try with the JS codde below:

    $(document).ready(function () {
        //$('.js-dialog').magnificPopup({
        //    type: 'inline',
        //    preloader: false,
        //    modal: true
        //});
    
        $('.js-click-me').on('click', function (e) {
            alert('hello');
            e.preventDefault();
        });
    
        $('.dropdown-toggle').dropdown();
    
        $('.js-dialog').on('click', '.js-dialog', function (e) {
            e.preventDefault();
    
            //(function ($) {
            $.magnificPopup.open({
                type: 'ajax',
                modal: true,
                items: {
                    src: $(this).attr('href'),
                }
            });
            //}).apply(this, [jQuery]);
        });
    });

    * Note the event click directly on element instead of document.
    * Note the dropdown initialized using javascript.

    Please, try that and let me know if you need further assistance.

    Kind Regards,

    Rodrigo.


    #10025619

    stesvis
    Participant

    Hi Rodrido, in that same page, now when you click the button i open a modal dialog.

    Do you know why it would take to clicks on Cancel to close the dialog?
    The first click seems to only close the sidebar, the second click closes the dialog.

    Ideally the first click should close the dialog but not close the sidebar.

    Thanks


Viewing 3 posts - 1 through 3 (of 3 total)