Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7006317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:27:44+00:00 2026-05-27T21:27:44+00:00

I am using nodejs. And calling something like the following from a javascript file:

  • 0

I am using nodejs. And calling something like the following from a javascript file:

$("#right").append(resp);

I then initialize it as a datatable but all the functions (like doubleclick) defined on datatables don;t work. If I copy the code for the doubleclick into the console it works.

What am I doing wrong?

Edit: more info. So what I have now is when a user logs in it displays their playlists in a sidebar using ajax. When the playlist is clicked it loads that playlists. However, the code in application.js(loaded initially) does not apply to the playlists unless the page is fully reloaded.

Here is some code I have:

    $.ajax({
  type: "POST",
  url: '/login',
  data: {  email: email, password: pass },
  success: function(result) {
    $.get('/toop', function(data) {
    console.log(data);
    if (data == "fail") {
      alert("error");
    } else {
    $("#header").html(data);
    $(document).trigger('close.facebox');
    $.get('/getPlaylists' , function(playlists) {
    $("#left").html(playlists);
    });

This just gets the playlists for the users and puts them on the sidebar. Now in the application.js file I have:

    $(".user-playlist").click(function(e) {
    var playlist = e.target;
    var id = $(playlist).attr('data-playlist');

.
.
.
.

But it only detects a click of the playlist if I do a full refresh of the page. Just rendering it using ajax doesnt. I am doing {layout: false} when getting the new view. Do I have to reload application.js? I am new to node (and web dev). Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:27:45+00:00Added an answer on May 27, 2026 at 9:27 pm

    The click event handler will only be applied to the set of elements which match .user-playlist when $(".user-playlist") is called. To see which elements those are, open the web inspector (or Firebug) and add this line just before the JavaScript snippet you included in your post:

    console.log($(".user-playlist"))
    

    You should see an empty array on the page where the playlist is loaded from Ajax, and at least one item on the page after a full refresh.

    To attach the event handler even for elements which are not on the page yet, read the documentation for the on method (specifically, the functionality that used to belong to the live method).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NodeJS under Windows (with node.exe downloaded from NodeJS site). I would like
Im using the following code to output all the nodes from the xml shown.
I want to append some nodes to an xml document using Linq2XML. The file
Any one help me . I am using the following code for calling web
I'm looking for a pure javascript, open-sourced, wiki implementation, preferably one using NodeJS. Where
I'm currently using the Nokogiri::XML::Builder class to construct an XML document, then calling .to_xml
Maybe it's just the fact that I've been using http://nodejs.org/ lately, but the lack
I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany
I would like to select a node and modify its attributes and child-nodes using
I want to realize a simple client-server connection using Nodejs. But I've encountered with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.