Skip to content

Commit

Permalink
fix target="" attribute not showing all entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Bearded Avenger committed Jun 18, 2015
1 parent 96266cd commit 651bc19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions public/assets/js/wp-live-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
var backboneTemplate = $('#wpls--tmpl')
, itemTemplate = _.template( backboneTemplate.html() )
, posts = new wp.api.collections.Posts()
, main = '#wpls'
, postList = '#wpls--post-list'
, postList = $( postList ).data('target') ? $( postList ).data('target') : postList
, postList = $( main ).data('target') ? $( main ).data('target') : postList
, results = '#wpls--results'
, loader = '#wpls--loading'
, input = '#wpls--input'
Expand All @@ -20,7 +21,6 @@
, api = WP_API_Settings.root
, timer


$( input ).on('keyup keypress', function ( e ) {

// clear the previous timer
Expand All @@ -32,7 +32,7 @@
, valEqual = val == $(that).val()
, notEmpty = '' !== val
, type = $(this).data('object-type')
, total = $(postList).data('number')
, total = $( main ).data('number')
, url = api+'/'+type+'filter[s]='+val+'&filter[posts_per_page]='+total

// 600ms delay so we dont exectute excessively
Expand Down Expand Up @@ -64,6 +64,8 @@
// make the search request
$.getJSON( url, function( response ) {

console.log(response)

// remove current list of posts
$(postList).children().remove()

Expand Down
4 changes: 2 additions & 2 deletions public/includes/class.shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function shortcode( $atts, $content = null ) {
ob_start();

?>
<div id="wpls" class="wpls <?php echo esc_attr( $mode );?>" itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
<div id="wpls" class="wpls <?php echo esc_attr( $mode );?>" itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction" <?php echo esc_attr( $number );?> <?php echo esc_attr( $target );?>>

<div class="wpls--results-wrap">
<span id="wpls--results"></span>
Expand All @@ -54,7 +54,7 @@ public function shortcode( $atts, $content = null ) {
<div id="wpls--loading" class="wpls--loading"><div class="wpls--loader"></div></div>
</div>

<ul itemprop="target" id="wpls--post-list" <?php echo esc_attr( $number );?> <?php echo esc_attr( $target );?>></ul>
<ul itemprop="target" id="wpls--post-list"></ul>

</div>

Expand Down

0 comments on commit 651bc19

Please sign in to comment.