-
AuthorSearch Results
-
December 1, 2016 at 11:03 am #73431
In reply to: update filter element through javascript?
RossKeymasterHey Ash
I’ve not tried to do what you are doing exactly but in theory it should work.
So you want to clear one field if the other field is updated?
I think what you are doing is fine, setting
.val("")
.. when doing this, do you see the field itself change value? If so, then all you should need to do is submit the form (which will handle the building of the new URL) –$('.searchandfilter').submit();
– this will also work for an ajax powered search form.What you suggested above also sounds like it might do the trick (triggering a change event after you have set the val), you might need to trigger
input
orchange
and then you would need to do it here in your example:jQuery('.sf-field-taxonomy-taxonomy1 select').on('change',function(){ jQuery('.sf-field-taxonomy-taxonomy2 select').val('').trigger('change'); });
Our next major version has quite a large rewrite and will include a JS api for doing this kind of thing much more easily.
Hope that helps
November 30, 2016 at 9:05 pm #73386In reply to: update filter element through javascript?
AnonymousInactiveOne more question,
If I set dropdown value from another filter element’s event,
url query string remains and result is different from what I expected.jQuery(‘.sf-field-taxonomy-taxonomy1 select’).on(‘change’,function(){
jQuery(‘.sf-field-taxonomy-taxonomy2 select’).val(”);
});url query strings after update
/search/?_sft_taxonomy1=xxx&_sfm_taxonomy2=yyy
_sfm_taxonomy2 should be removed.November 14, 2016 at 11:29 am #70110In reply to: Using buttons for search criteria
TrevorParticipantThe script would more likely look like this:
<script type="text/javascript"> jQuery(document).ready(function($){ document.getElementById("myButton").onclick=function() { $('.myselectorclassname').val('hello'); } }); </script>
Exactly what your code will look like depends on what it is you are doing and want to achieve, and stackexchange is the best place to look for examples. The way I have written the code above
is not how WordPress would say to do it, but it generally works for me.
If you have a results shortcode on a page, that page should put the results there, yes.July 20, 2016 at 6:41 am #51682Topic: Hide a field when i choose an option
in forum Search & Filter Pro
AnonymousInactiveHello, I have a question , I tried to hide a field by choosing an option from a select field, but only do it once, and not do it again when I select another, I have tried with jquery “switch and on change”.
I have a select with various states of Mexico , when I choose a state , a select field must appear with other cities of that state, but only does the first time i choose a state.
Example
$(".sf-field-post-meta-estado .sf-input-select").change(function(){ var id = $(this).find("option:selected").val(); switch (id){ case "Nuevo León": $('.sf-field-post-meta-coahuila').hide() $('.sf-field-post-meta-nuevoleon').show() break; case "Coahuila": $('.sf-field-post-meta-nuevoleon').hide() $('.sf-field-post-meta-coahuila').show() break; } });
.sf-field-post-meta-estado .sf-input-select
is the select field of the states of mexico with options like “Nuevo León, Coahuila”.sf-field-post-meta-coahuila, .sf-field-post-meta-coahuila
These are the city containers of their respective statesHow could I accomplish that?, I think some script is interfering, idk.
cheers!
May 12, 2016 at 3:32 pm #45395In reply to: Display results page issue
TrevorParticipantDoes the http://sustainablepackaging.valipac.be/knowledge-base/ also use the same hkb-templates/hkb-archive.php page?
April 26, 2016 at 4:44 pm #43980In reply to: How to style the search data
TrevorParticipantHi. So, using javascript, this is how reset a field value (for example the length):
jQuery(".sf-field-taxonomy-length .sf-input-select").val("");
I think this is correct. I am sure if Ross sees this, he will let us know if it isn’t.
and then to submit the form:
jQuery("#search-filter-form-339").submit();
March 20, 2016 at 1:29 pm #39906
AnonymousInactiveHi,
Here is the code of the archive that i use to display results (results.php):
and here i put a screenshot of the display results tab config:
http://www.valladolidesquelas.com/wp-content/uploads/2016/03/display_options.png
Thanks.
March 19, 2016 at 11:51 am #39849In reply to: Group sets of fields
AnonymousInactiveHi Ross,
Thanks for the update.
I’ve come up with a work around until then, where I have a dummy text input where I want to display it, and have the value copied across to a hidden text input within the form.
If anyone else is interested in doing it, here’s the jQuery I’m using to copy the value and update the search results.
$('#search').on('keyup click change', function(event) { $('.sf-input-text').val($('#search').val()); $('.searchandfilter').submit(); });
March 18, 2016 at 5:33 pm #39828In reply to: Combo box for post title?
AnonymousInactiveHi Ross
Yes that’s exactly what I mean.
<select class="chosen-select" multiple tabindex="4" name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\"><?php echo attribute_escape(__('Properties by Title')); ?></option> <?php wp_get_archives('type=postbypost&format=option&post_type=property'); ?> </select>
This works outside of S&F and I noticed you used Chosen by Havest to make the nice combo boxes – so I can do that. It would be nice if I could somehow integrate it within S&F as part of a form instead of by itself. Can I do that?
February 17, 2016 at 11:27 am #37190
AnonymousInactiveyes I’ve tried something like this
(function($) { var disableselect = function(){ if ($('select[name="price"]').val()) { $('select[name="part"]').prop('disabled', true); }; if ($('select[name="part"]').val()) { $('select[name="price"]').prop('disabled', true); }; } $(document).ready(disableselect); $(document).on("sf:ajaxfinish", ".searchandfilter", disableselect); })(jQuery);
and it works when you refresh page, but I need it to work on “ajaxfinish”. Am I using it properly? Is there any event after ajaxfinish? I can see it’s disabled for a moment but then enabled again.
Any idea? Sorry, I know this is not very S&F question anymore 🙂 -
AuthorSearch Results