potomak / jquery-instagram

Instagram jQuery plugin
http://potomak.github.io/jquery-instagram/
MIT License
555 stars 143 forks source link

Using text input to change hash won't change tag in next_url #6

Closed macsupport closed 12 years ago

macsupport commented 12 years ago

I'm trying to add the ability to change the hash in a text input (selectedHash) and then have new images with this new tag load when the "more" button is pressed as in your example code. I can see in the console that the hash changes but not the url. Obviously I'm missing something as to getting the tag in the next_url to change. Any help would be appreciated! Here is my code.

     var selectedHash = $( "input:text[name=hash]" ).val(); 
  var
    insta_container = $(".instagram")
  , insta_next_url

  insta_container.instagram({
       next_url : insta_next_url,
      hash: selectedHash
    , clientId : '4cc3fc9df774483cb575b405f3c1cc21'
    , show : 5
    , onComplete : function (photos, data) {
      insta_next_url = data.pagination.next_url
    }
  })

  $('button').on('click', function(){
      var selectedHash = $( "input:text[name=hash]" ).val();
    var 
      button = $(this)
    , text = button.text()

    if (button.text() != 'Loading…'){
      button.text('Loading…')
      insta_container.instagram({
          next_url : insta_next_url,
          hash: selectedHash
        , show : 5
        , onComplete : function(photos, data) {
          insta_next_url = data.pagination.next_url

          button.text(text);
            console.log( selectedHash )
            console.log( insta_next_url )
        }
      })
    }       
  }) 
});
potomak commented 12 years ago

Please put a working example on http://jsfiddle.net/

macsupport commented 12 years ago

Here is a fiddle. You can see the hash change but not the insta_url

http://jsfiddle.net/macsupport/NZ8Yu/

My page in process, using Instagram and Jquery Isotope:

http://http://www.instagraminate.com/boot.html

potomak commented 12 years ago

Well, you're passing next_url option to instagram() call, this way the plugin ignores other options, see https://github.com/potomak/jquery-instagram/blob/master/jquery.instagram.js#L51.

See if this version works for you: http://jsfiddle.net/NZ8Yu/55/