The AngularJS framework does not support the Twitter Collection Grid feature

I'm currently facing an issue with implementing a Twitter Collection Grid on my website using an angularJS directive. The grid is not displaying correctly, as the pictures are stacking on top of each other instead of forming a grid layout. I've tried resizing the widget but it doesn't seem to resolve the issue. Interestingly, the grid works correctly about 25% of the time when I reload the page. Here's the code snippet I'm using:

<div id="twitter-collection">
  <twitter-collection></twitter-collection>
</div>

And here is the directive code:

.directive("twitterCollection", [ function() {
  return {
  restrict: 'E',
  template: '<a class="twitter-grid" href="https://twitter.com/_/timelines/539487832448843776">Tweets with pictures</a>',
  link: function(scope, element, attrs) {
    function run() {
      (! function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0],
          p = /^http:/.test(d.location) ? 'http' : 'https';
        if (!d.getElementById(id)) {
          js = d.createElement(s);
          js.id = id;
          js.src = p + "://platform.twitter.com/widgets.js";
          fjs.parentNode.insertBefore(js, fjs);
        }
      }(document, "script", "twitter-wjs"));
      console.log('run TwitterCollection script');
    }
    run();
   }
  };
}])

Has anyone else encountered this issue or successfully implemented the Twitter Collection Grid? I would appreciate any insights on how to resolve this problem. Thank you!

Answer №1

After ditching the directive and opting for a pure HTML approach like the example code below, I successfully got it to display in a grid formation every time I reload the page.

<div id="twitter-collection" style="width: 80%;">
  <a class="twitter-grid" href="https://twitter.com/_/timelines/666933617080299521">A Collection on Twitter</a>
</div>
<script async defer src="https://platform.twitter.com/widgets.js"></script>

I initially attempted to use a directive to showcase the collection due to issues with the standard HTML code provided by Twitter for a "normal" timeline widget. That code did not function properly as the widget failed to reload when navigating away from the page and returning. Implementing a directive for the timeline ultimately resolved this problem.

Answer №2

If you're in need of it, you can utilize:

personalized twitter feed script - `https://jsfiddle.net/uniqueuser/9x9fc/`

https://github.com/JohnDoe/Tweet.js-Mod

I trust this information proves helpful to you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unique Google Maps API V3 PEGMAN Customization

Can custom zoom controls and Pegman controls be styled with the same design? To add custom zoom controls, follow the instructions provided in this question's answer: <!DOCTYPE html> <html> <head> <meta name="viewport" cont ...

How can I implement the vm. syntax using ControllerAs in my application?

After reading various sources, including a few discussions on Stack Overflow, I have come to understand that the ControllerAs syntax is gaining popularity as it aligns with how things are done in Angular 2. Therefore, I decided to delve deeper into unders ...

jQuery includes inArray as the final element in an array or object

There's a strange issue I've noticed where, in some cases, when jQuery is imported, it appends the inArray function as the last element of a defined object or array. This can cause problems with for ... in loops since it counts this unexpected fu ...

Importing d3.JS JSON data without polluting the global scope

Here is a JSON object: { "temp_data": [10,15,20] } I'm trying to import it: var temp_data; //Importing from JSON if(true){ d3.json("graph.json", function(error, graph) { if (error){ throw error; } temp_da ...

Leverage jQuery to loop through a JSON array containing WordPress coordinates generated by Advanced Custom Fields and JSON API

I am currently working with a custom field named coordinates to display a Google Map within a Wordpress post. To achieve this, I am utilizing two plugins: Advanced Custom Fields and JSON API. The resulting JSON array looks like this: {\"address\ ...

In the context of Express, how are "static" and "non-static" defined?

The Express documentation explains that the express.static() middleware is used to serve static files like images, CSS, and JavaScript. However, when serving a front-end React app using express.static("some_build_dir"), which includes JS files ...

Update the ng-view within ng-view with new content

Greetings, I am currently in the process of developing a single page application using Angular. Below is an excerpt from my index.html file: <!DOCTYPE html> <html lang="en" ng-app="onlineApp"> <head> <meta charset="UTF-8"> ...

What is the method for determining the number of unique tags on a webpage using JavaScript?

Does anyone have a method for determining the number of unique tags present on a page? For example, counting html, body, div, td as separate tags would result in a total of 4 unique tags. ...

Challenge involving CSS and Javascript for solving puzzles

In my attempt to create a puzzle with 2 rows and 3 columns using CSS and JavaScript, I envision the pieces of the puzzle being black and cut into various shapes. The objective is for users to drag these pieces onto the board in order to complete it. I have ...

AngularJS encounters bad configuration on 'GET' request

I am facing an issue with my API that returns data to AngularJS based on a given ID. When the data is returned as JSON, AngularJS throws a 'badcfg' error, indicating that it could be due to the format of the returned data. I'm struggling to ...

Transmitting POST form information from an AngularJS client to an Express/Node.js server

I am currently facing an issue where the data from my AngularJS form is not reaching the Express server, despite the client function executing successfully. I suspect there might be a problem with the URLs being used. Snippet from my AngularJS controller: ...

Why using $refs in interpolation fails and leads to errors in Vue.js 2.x components

Here is a codepen I created: codepen const sidebar = { name: "sidebar", template: "<p>SIDEBAR</p>", data() { return { active: true }; }, methods: { test() { alert("test: " + this.active) } } }; new Vue ...

What is the process for configuring the Authorization Header in ng2-signalr?

I am currently utilizing the library ng2-signalr within my ionic 2 project. I am facing an issue regarding setting the authorization header, as I have been unable to find any examples on how to do so. Below is my code snippet for establishing a connection ...

Is it necessary to invoke $apply in AngularJS even if there are no modifications to the model?

Hello fellow developers, When I make changes to an HTML native attribute, such as a division's class, within an event handler, is it necessary to wrap it in a call to $apply? In simpler terms, can these native attributes be watched? For instance, I ...

The getter function is called before the v-if directive in the child slot component

I have developed a Vue component that needs to perform certain logic and based on that logic, I want to render the content inside the slot. <logic-component> <div>{{ data }}</div> </logic-component> The data is retrieved using a ...

Tips for implementing a search function with DynamoDB using the "contains" operator

I'm currently working on implementing a search function in my React application. Here is the structure of my DynamoDB table: --------------------- movie_id | movie_name --------------------- 1 | name a --------------------- 2 | name b ...

Unable to reach redux actions through props while using react router

As someone who is new to working with React and Redux, I've been encountering an issue with accessing my Redux actions from the props when using them alongside React Router. Despite trying various configurations, the props only seem to contain the Rea ...

Top method for developing a cohesive single-page application

Many websites are incorporating JSON data in string format within their page responses, along with HTML: For example, take a look at https://i.sstatic.net/bDU7X.png The benefit of rendering JSON in string format within the page response is that it allow ...

What could be causing the returned promise value to not refresh?

I am currently facing an issue with my program. Upon clicking a button, the goal is to update the "likes" attribute of a MongoDB document that has been randomly fetched. Despite setting up the logic for this, the update does not occur as intended: MongoCli ...

Step-by-step guide on building a mat-table with nested attributes as individual rows

Here is the data structure I am working with: const families = [ { name: "Alice", children: [ { name: "Sophia" }, { name: "Liam" ...