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

Related Questions

I am somewhat new to jQuery but have been having fun trying learn about
I have just started a new job out of uni and I am learn
So I am pretty new to JQuery and just spent 5 hours getting this
I just set up my new homepage at http://ritter.vg . I'm using jQuery, but
Ok, I am new to JQuery, I have a modal that has a asp:Literal
I'm brand new to jQuery (and javascript in general). I've been meaning to use
I'm fairly new to jQuery and just started working with jqGrid. I've looked over
I am VERY new to jQuery. Just trying to get a feel. I like
I am brand new to Jquery and have run into something that if answered
I'm new to jquery and asp.net so please forgive if this is an obvious

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.