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

  • Home
  • SEARCH
  • 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 100377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:34:05+00:00 2026-05-11T00:34:05+00:00

I am new to jQuery.just learn and use it for 3 weeks until now.

  • 0

I am new to jQuery.just learn and use it for 3 weeks until now. I have written a class to organize stuff. I call my method with more than 2 events,but the event does not work during my trigger of the second event. there’s nothing wrong with the selector. I think there’s something missing in my class. I don’t know. please help! here’s the snippet:

$('#btnPersonalNext, #btnDocListBack, #pDocList').livequery('click',function() {   var docListContent = 'loadDocumentList.php';   $('#contentpaper').addContent(   {     _tag:'div',     _id: 'contentDocList',     _class: 'content',     _content: docListContent,     _heading: 'Document List'   });   //store personal info in session: }); 

addContent() is the function. when I click #btnPersonalNext,this works, but for #btnDocListBack, not any-more.

here’s my class (jquery.content.js). what it does is load html into a certain _tag with a particular _id.

(function($) {   $.fn.addContent = function(options)   {     var defaults = {       _tag: 'div',       _id: '',       _class: '',       _content: '',       _heading: '',       _clearExisting:'yes',       _insertAfterID:'',       _deleteBeforeInsert:'no'     };     var options = $.extend(defaults, options);      return this.each(function()     {       obj = $(this);       if(options._clearExisting=='yes'){         obj.empty();       }       if(options._deleteBeforeInsert =='yes'){         $('#'+options._id).remove();       }        var innerHtml = '<' + options._tag + ' id='' + options._id + '' class='' + options._class + ''>';       if(options._heading!=''){         innerHtml += '<h2>' + options._heading + '</h2>';       }        if(/^[A-Za-z0-9]+\.php(\??([A-Za-z0-9]+=[A-Za-z0-9]+)(&[A-Za-z0-9]+=[A-Za-z0-9]+)*)?$/.test(options._content))       {//if .php         $.get(options._content,function(data)         {           //handle response from server here.           innerHtml += data;           innerHtml +='</' + options._tag + '>';           if(options._insertAfterID !=''){             $('#'+options._insertAfterID).after(innerHtml);           }           else{             obj.html(innerHtml);            }         });       } // PHP rule        else       {// .html         innerHtml += options._content;         innerHtml +='</' + options._tag + '>';         if(options._insertAfterID !=''){           $('#'+options._insertAfterID).after(innerHtml);         }         else{           obj.html(innerHtml);          }       } // HTML rule      }); // End of Returned Function   };// End of addContent definition })(jQuery); 

hoping for answers, thank you so much!

here’s my DOM structure:

 <!-- JS  --> <script type='text/javascript' src='jquery_plugins/jquery-1.2.6.js' ></script> <script type='text/javascript' src='jquery_plugins/jquery.livequery.js' ></script> <script type='text/javascript' src='jquery_plugins/jquery.simplemodal.js'></script> <script type='text/javascript' src='jquery_plugins/jquery.session.js'></script> <!--<script type='text/javascript' src='jquery_plugins/jquery-plugin-wrapinner.js'></script>--> <script type='text/javascript' src='jquery_plugins/jquery.content.js'></script> <script type='text/javascript' src='jquery_plugins/osra_main.js'></script> </head>  <body> <div id='wrapper'>        <div id='header'>         <div id='headercontent'>Please Enable JavaScript to Continue</div>     </div>     <div id='main'>         <div id='sidebarpaper' class='left'>             <!-- sidebar contents (class='sidebar')-->         </div>         <div id='contentpaper' class='right'>             <!-- main contents (class='content')-->         </div>         <div id='modals' class='clear'>             <!--modal pop-up window -->         </div>     </div>     <div id='footer'><p></p></div> </div> </body> </html> 

I am loading the content dynamically in div with id #contentpaper. I don’t know how to rebind, other that using livequery plugin, with this usage: $('#btnID').livequery('click',function(){});

-bgreen1989

  • 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. 2026-05-11T00:34:05+00:00Added an answer on May 11, 2026 at 12:34 am

    I gave it a quick look over and the code size was a little hard to diagnose, so I re factored a bit hoping to make it more understandable to myself and others.

    What I think is PART of the problem and a BADTHING(TM) is your generation of html by gluing strings together. This can break DOM event binding, and render really awful code.

    Also, seeing you are relying on live-query, the ‘glue strings together’ method may not be triggering the dom events required to make live-query trick (Not Certain) and you /may/ find using DOM methods to generate DOM elements should solve this problem

    (function($){   $.fn.addContent = function(options)   {     var defaults = {       _tag: 'div',       _id: '',       _class: '',       _content: '',       _heading: '',       _clearExisting:'yes',       _insertAfterID:'',       _deleteBeforeInsert:'no'     };     var options = $.extend(defaults, options);     var phpregex = /^[A-Za-z0-9]+\.php(\??([A-Za-z0-9]+=[A-Za-z0-9]+)(&[A-Za-z0-9]+=[A-Za-z0-9]+)*)?$/;      var x_generateElement = function()     {       var container = document.createElement(options._tag);        $(container).attr('id', options._id);        $(container).addClass(options._class);       if(options._heading!=''){         var header = document.createElement('h2');          $(header).text( options._heading );          $(container).append(header);       }       return container;     };      var x_preClear   = function( obj )     {       if(options._clearExisting=='yes'){         obj.empty();       }       if(options._deleteBeforeInsert =='yes'){         $('#'+options._id).remove();       }       return obj     };      var x_addElement = function( e , obj )     {             if(options._insertAfterID !=''){             $('#'+options._insertAfterID).after(e);       }       else{         obj.html(e);        }       return obj;     };      return this.each(function()     {       var obj = x_preClear( $(this) );       var container = x_generateElement();         if( phpregex.test(options._content)){         $.get(options._content,function(data){           //handle response from server here.           $(container).append(data);           obj = x_addElement(container, obj);         });       } else {         $(container).append(options._content);         obj = x_addElement(container, obj);       }      });   }; })(jQuery); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For frequent uploads of small files, the fastest way would… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer Symbolic equation solving is a complex problem and there is… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer Have you tried having the ID be TEST.html? My guess… May 11, 2026 at 4:01 pm

Related Questions

Using core jQuery, how do you remove all the options of a select box,
I have recently been thinking alot about where to draw the line, and I
So I am pretty new to JQuery and just spent 5 hours getting this
I am new to JQuery. I'm reading JQuery in action, but only up to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.