Giter VIP home page Giter VIP logo

Comments (6)

CliqLabs avatar CliqLabs commented on May 30, 2024

In that case, try doing something like this when initializing the plugin:

$(document).on("rateit", ".rateit", function() { ... }); // .rateit here is the selector for the div element that you created that holds the stars

The idea here is to bind to the document itself (which always exists) so that the target element is determined at runtime instead of at DOM-load time. I do this kind of thing all the time when creating single-page web apps that are entirely AJAX-driven and where elements come and go from the DOM frequently. The binding is effectively deferred until the time that the event occurs instead of when the DOM is first loaded.

from rateit.js.

gjunge avatar gjunge commented on May 30, 2024

@CliqLabs , thanks for providing the explanation. Closing issue.

from rateit.js.

Nexotap avatar Nexotap commented on May 30, 2024

I know, this issue is closed. But maybe you can give me a foolproof example of how to do it? That would be very kind.
I just dont get it. Thanks in advance.

from rateit.js.

gjunge avatar gjunge commented on May 30, 2024

Hi @Nexotap . Please see my jsfiddle here: https://jsfiddle.net/gidon/w12zkh50/

from rateit.js.

Nexotap avatar Nexotap commented on May 30, 2024

Thank you very much. Helped me alot.
Btw. Very nice plugin 👍

from rateit.js.

javaboyjunior avatar javaboyjunior commented on May 30, 2024

Wanted to add my findings for those facing the same issue. I have a DIV that gets loaded with data via an AJAX call and includes a rateit component.

I found adding this does the trick:

$( document ).ajaxComplete(function() {
$( ".rateit" ).rateit();
});

This initializes all DOM elements of class .rateit after any AJAX calls are complete. Works great.

gjunge - thank you for this component!

from rateit.js.

Related Issues (20)

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.