Forums Forums Search & Filter Pro Jquery UI preventing ajax auto submit?

Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #22820

    Hi,

    Firstly I think this plugin is great – and I’ve been through a few.

    I have a little issue and i wonder if you can shed some light. I am trying to run Jquery UI to override the select menus and allow them to be styled better;

    ( ".postform" ).selectmenu();

    It over-rides the styles fine but unfortunately prevents the Ajax auto submit. Using a submit button works fine. Is there something I should be doing to allow this?

    Ross Moderator
    #22822

    I guess doing that replaces the event handlers on the object so you would need to try to recreate the effect of the auto submit.

    So something like

    $(document).on('change', '.searchandfilter select', function(){
    	$('.searchandfilter').submit();
    });

    In the actual S&F autosubmit there is a a setTimeout which gives a small delay before submitting allowing for further user input. If the user interacts with the form any existing timeouts are cancelled, and a new timeout is called with the submit function.

    The next version of S&F has quite a bit of a JS rewrite and there are some easy ways to unload and reload the script associated with with S&F which would probably be what you want to be using after the update – although above advice should still be sound.

    Thanks

    Anonymous
    #22846

    Thank you, that steered me in the right direction.

    Unfortunately it still was;t quite right, and with my limited javascript knowledge, I had to do a little workaround as the page was reloading rather than using Ajax.

    However, by adding a submit button I then hid it using CSS. I then used this script to allow a click function to be performed on it

    $('.searchandfilter select').on('selectmenuchange', function(e) {
    e.preventDefault();
    $('.sf-field-submit input').click();
    });
    

    It works, but it’s a little bit hacky. If you have any more ideas that would be great.

    Looking forward to the new version.

    Thanks.

    Ross Moderator
    #22847

    Cool not sure really, I think its better to wait for hte new version and replace the code above, its almost ready – trying to find a couple of days to finish it off.

    Thanks

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