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 9032609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:01:18+00:00 2026-06-16T08:01:18+00:00

So I am trying to get this code below to work with updating a

  • 0

So I am trying to get this code below to work with updating a price based on an ajax onclick:

$('#main_body li[data-pricefield="special"]').delegate('onclick','change', function(e)
{
    var temp = $(this).attr("id").split('_');
    var element_id = temp[1];

    var pricedef = $(this).data('pricedef');
    if(pricedef == null)
    {
        pricedef = 0;
    }

    $("#li_" + element_id).data("pricevalue",pricedef);
    calculate_total_payment();
});

Things seem to be working ok so far – when I type in the console:

jQuery('#li_273').data('pricevalue');

I do get a value of “1.00” returned which is actually being set here on the onclick command:

'onclick' => 'jQuery(\'#li_273\').data(\'pricevalue\',\'1.00\');',

My question is what is wrong with my first block of code that is stopping this from calculating the price the right way and how do I correct it?

  • 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-06-16T08:01:19+00:00Added an answer on June 16, 2026 at 8:01 am

    You are using

    $('#main_body li[data-pricefield="special"]').delegate('onclick','change', function(e){
       // ...
    });
    

    but delegate‘s syntax is .delegate( selector, eventType, handler(eventObject) ) and in this case you should write

    $('#main_body').delegate('li[data-pricefield="special"]','click', function(e){
       // ...
    });
    

    There is no onclick event in jQuery and AFAIK an li doesn’t have a change event so if you want to use multiple events then you can use

    $('#main_body').delegate('li[data-pricefield="special"]','click another_event', function(e){
       // ...
    });
    

    Also you can use on instead of delegate.

    An Example and Read more.

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

Sidebar

Related Questions

Forgive me for this unbeautiful code, but I'm trying to get it to work
I've been trying to get this code to work for hours! All I need
I've been trying to get this code to work for the past day whilst
I'm trying to use Ajax of jQuery, I have this code below and although
Hey all i am trying to get my code below to work in order
Hey all i am trying to get my jquery code below to work: function
I'm trying to get this C++ code to input a series of numbers from
i am new in programming under linux and trying to get working this code:
I am trying to get this piece of code working in C#, what I
I'm trying to play video from youtube using this code but I get this

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.