Code Monkey home page Code Monkey logo

Comments (5)

VincentLoy avatar VincentLoy commented on July 19, 2024

Hi miguel ! Can you tell me how did you initialized tweetParser in your webpage and which version of tweetParser are you using with ?

However, would this may be caused because tweetParser is loaded before that your template is generated ?
If it's the case, you may try to load tweetParser once everything is loaded into your page like so 👍

<!-- some code here -->

<p class="tweet"> this is a nice tweet #chido </p>

<!-- some code here -->
(function () {
    // your js logic stuff

    window.setTimeout(function () {
        tweetParser('.tweet');
    }, 0);
}());

Hope it'll help.

from tweetparser.js.

miguelcarvajal avatar miguelcarvajal commented on July 19, 2024

Thanks, @VincentLoy. I have tried your solution, but it is still not working. Tweetparser is loaded after everything is loaded. The handlebars template that I am using is this one:

<div id="content"></div>    
<script id="cat-template" type="text/x-handlebars-template">
<p class="tweet">This is my awesome text only tweet ! #web #twitter @twitter http://www.twitter.com/ !!</p>
<p class="tweet">{{Status}}</p>
</script>

None of the tweets work under the cat-template from Handlebarjs. If I put them outside, the do work.

I am using this tweetParser.js v2.2.0 with your code above and the one in the example. Both seem to work under html but not under this handlebars template:

<script type="text/javascript">
      var public_spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1_uOy7-BLbB3AE5qTxnU_Z6zIKnwzN88iq_wPCP4NLmA/pubhtml';
      $(document).ready( function() {
        Tabletop.init( { key: public_spreadsheet_url,
                         callback: showInfo,
                         parseNumbers: true } );
      });

      function showInfo(data, tabletop) {
        var source   = $("#cat-template").html();
        var template = Handlebars.compile(source);
        $.each( tabletop.sheets("Cats").all(), function(i, cat) {
          var html = template(cat);
          $("#content").append(html);
        });
      }
</script>

And finally this is the tweetParser set up:

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/0.0.1/prism.min.js"></script>
<script src="tweetparser.js"></script>
<script>
      window.setTimeout(function () {
        tweetParser('.tweet');
    }, 0);
</script> 

Thanks for your help.

from tweetparser.js.

VincentLoy avatar VincentLoy commented on July 19, 2024

mmmh ok, I made some tests with mustache.js that provide similar stuff like handlebars (for templates rendering) and I reproduce the same bug.

So, does handlebars provide a callback function on template rendering end ? I think that is the solution. Because When I run this code :

window.setTimeout(function () {
    tweetParser('.tweet');
}, 1500);

it work perfectly. I really think that you have to wait the template rendering end before calling tweetParser :)

from tweetparser.js.

miguelcarvajal avatar miguelcarvajal commented on July 19, 2024

Wow! It works! Thank you very much. This is really saving me a lot of time!

Best regards!

from tweetparser.js.

VincentLoy avatar VincentLoy commented on July 19, 2024

Nice ! Saludos !

from tweetparser.js.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.