Reloading canvas javascript after ajax call -


scenario: canvas based portfolio items listed ajax driven pagination.

problem: after loading next page of content ajax, script tags aren't inside canvas tags.

tried: adding script tags before canvas tags, isn't loaded either (so problem loading scripts).

research: jquery script not working, apparently can't retrieve scripts because of security.

possible alternative: adding canvas content outside canvas tags, difficulty comes in passing dynamically created portfolio title tags!

code:

    <ul id="products-list">         <?php             $i = 0;             while($the_list->have_posts()): $the_list->the_post(); //wordpress loops through posts         ?>          <li  class="product-item<?php echo $i;?>">             <script>functionformakingacanvasoverlayusingtheposttitle("<?php echo get_the_title() ?>");</script>             <canvas></canvas>         </li>          <?php $i++; ?>        <?php endwhile; ?>     </ul> 

6 items shown per page , next button uses ajax call next 6 items

suggestions? thanks.

myyou can't add javascript code using ajax without calling hated eval method. , in case, don't need to. answer call external javascript on object, rather calling javascript directly. code you've given sparse, idea below purely demonstration purposes - you'll need translate actual situation:

<canvas><div id="mytitle"></div></canvas> <script>     function drawtitleoverlay(title){         var titleoverlayhtml = buildtitleoverlayhtmlfromtitle(title);         document.getelementbyid('mytitle').innerhtml = titleoverlayhtml;     }      function nextpage(){         var data = getajaxdata();         var title = gettitlefromdata(data);         drawtitleoverlay(title);     } </script> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -