Forums › Forums › Search & Filter Pro › Reload JS that modifies form
- This topic has 7 replies, 3 voices, and was last updated 7 years, 9 months ago by Ross.
-
Anonymous(Private) January 30, 2017 at 6:09 pm #86800
Hi,
what s the right JavaScript Event if I want to reload my js file when
Auto submit is false
,Update the Search Form on user interaction is true
and `Load results using Ajax is false’. I can’t seem to get it right.I’m inserting one custom li item with JS in form but when I select some value in fields it messes up my fields.
Thanks
Ross Moderator(Private) January 31, 2017 at 5:03 pm #87118Hi there
If you modify the html structure of the form itself (the top level
li
) then yes, you are out of luck.As I’ve mentioned, the next version will support breaking out of the fields, which means you can place them wherever you want and in any html strucutre you desire.
As for adding classes etc…
If you have auto count ON, then when you perform a search, the search form is reloaded / fetched again (because the elements inside them can change, and also the count number should be updated).
This will reset any changes you make, in order to make changes to the form you will either use Javascript to add classes to various elements, and then after an ajax request re-apply that JS (JS events listed here) or you can use one of our filters to edit the classes on the input objects, but from a previous ticket I don’t think that’s what you want.
As to re-initialising S&F JS.. you can just do:
$('.searchandfilter').searchAndFilter();
Thanks
Trevor(Private) February 1, 2017 at 3:01 pm #87386From what I have read in this post, your requirement is to maintain what your custom js has done to a field control (adding an
<li>
when theAuto Count -> Update the Search Form on user interaction is true
does its stuff (when you change any filter in the form), BEFORE you hit Submit (because, when submit is hit, your js will run again anyway, as you have Ajax off).I think that the reply that Ross gave does not see that as a possibility, as he says but from a previous ticket I don’t think that’s what you want.
Not that I would recommend it, but I *think* that the form elements are built in this file:
class-search-filter-generate-input.php
(in public/includes)Ross Moderator(Private) February 1, 2017 at 3:08 pm #87390Yup the form elements are there, but thats not the whole “field” as some fields contain multiple form elements (like ranges).
Again, this is coming in v3, a class you can use to build your own fields.
The problem with the current version of S&F is thats it poorly decoupled and got bloated.
Its grown over 3 years, had 1 major refactor, and its due for another.
You’ll have a very hard time to create your own fields on the fly, and its not something I can easily explain I’m afraid.
All I can say is, look at the display-shortcode file, which outputs the html of the fields (the function is called
get_field
), that then relates to the others files you mentioned above (in the fields director), but you’ll have to figure out how so many other classes work, just because of poor decoupling.Thanks
-
AuthorPosts