ProBlog Search

Adds a search function to your problog

Back to ProBlog Search Support

paulgrafx
paulgrafx

Search is not working - the code below needs changing to make it work and force the javascript to load after jQuery.

components/searchform/default.htm

adding '{% put scripts %}' and '{% endput %}'

<h3 class="widgettitle">smart search</h3>

<p class="form-group">
    <input id="keyword" name="keyword" type="text" class="form-control" placeholder="Search" />
</p>

<button style="margin-top:10px;" id="search_detailed" type="submit" class="btn btn-success search_now">
    More Detailed Search <i class="fa  fa-chevron-circle-right"></i>
</button>

{% put scripts %}
<script type="text/javascript">
    $(document).ready(function(){
        $('#keyword').on('keypress', function (e) {
        var keyCode = e.which;
        if (keyCode == 13) {
            //Trigger click event
            $('.search_now').trigger('click');
        }
        });

        $('.search_now').click(function(){
            var term = $('#keyword').val();
            term = term.replace(' ','-');
            window.location =  "{{ __SELF__.resultPage|page({'filter': 'search', 'slug' : null}) }}" + '/' + term;
        });
    });
</script>
{% endput %}

1-1 of 1