Skip to content

DOM not updating when model changes on onclick #726

@mm-ns

Description

@mm-ns

I am using rivets to bind news stories i retrieve from http call to my dom; It's paginated so i load 3 at a time.

<section class="news-section">
                        <div class="col-12 post" rv-each-new="news">
                            <h5 class="h4capslight mb-3">{new.date}
                                <a href="" class="h4capslink">NEWS</a>
                            </h5>
                            <a href="#newsroom-post">
                                <h1 class="mb-3">{new.title}</h1>
                            </a>
                            <a href="#newsroom-post">
                                <p class="post-desc mb-4">{new.content}</p>
                            </a>
                            <a class="link-underline" href="#newsroom-post">Read More</a>
                        </div>
                        <div class="col-12 mt-5">
                            <nav aria-label="navigation">
                                <ul class="pagination">
                                    <li class="page-item" rv-each-page="numberOfPages" rv-on-click="loadPage">
                                        <a class="page-link" href="javascript:void(0)" value="index">{ index | mathadd 1 }</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </section>

in my js i do this:

        $.ajax({
        url: "api/items?",
        type: 'get',
        headers: {
           ....
        },
        data: {
         ....
        },
        success: function (r) {
         news = r.xyz;
         newsBinds = rivets.bind($('.news-section'), {
          news: news, 
          page: page,
          loadPage: function(e,model){
                  //here I tried to do another call to fetch more data or do a recursive call to this function.

                 then when i get the new data i do --> newsBinds.news = news;
          }
         })
        },error:function(xhr){
        }

the model is updated correctly in all various attempts i made but the html never gets updated. any ideas what im doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions