ryancw / instagram-scroll

Simple JavaScript file to load Instagram pictures of a certain tag and infinite scroll through them
14 stars 6 forks source link

rel attributes not working. #2

Closed ghost closed 9 years ago

ghost commented 11 years ago

Trying to run a "data-rel" in the link.attr so as to lightbox the image. Seems like it binds its events at the page load? Here is an example:

link.attr({'href' : obj.images.standard_resolution.url,'data-rel' : 'lightcase'});

ghost commented 11 years ago

EDIT: Issue has changed. The answer is for the previous question.

I think problem is the scope of your variables. 'tag_name' and 'client_id' are locally scoped inside the callback function, making them not accessible from the outside.

A solution could be declaring them outside the callback or passing them to a function doing the apropiate call to Instragram API, maybe?

2013/9/22 Nicos notifications@github.com

I am playing around with this. I want echo tag_name and client_id from mysql/php using ajax/json method. Cannot seem to get this working, any ideas?:

$.ajax({ url: 'call.php', dataType: 'json' }).done( function(data){ var tag_name = data[0]; var client_id = data[1]; } ); var thumb_dimension = 220; var div_to_add_pics = '#img'; var include_caption = false; var include_username = false; var url = ' https://api.instagram.com/v1/tags/'+tag_name+'/media/recent?client_id='+client_id ;

— Reply to this email directly or view it on GitHubhttps://github.com/ryancw/instagram-scroll/issues/2 .

ryancw commented 11 years ago

I'm going to clean this file up when I have time in the next few days, I created it when I had 0 knowledge of JS. I will allow params to be passed through the function call.