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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:12:49+00:00 2026-05-18T05:12:49+00:00

I’ve written a plug-in that constructs a rich UI control. I’m hoping that there’s

  • 0

I’ve written a plug-in that constructs a rich UI control. I’m hoping that there’s a way for me to somehow change how jQuery operate when I query for this element.

I’d like jQuery to be oblivious to the internal structure of this control, but it’s not really a hard requirement. What I’d like to do, is to change the meaning of $('#RichUIControlID').val() to some other function because #RichUIControlID is the wrapper element for this control (maybe i use a css class to identify that element).

Currently I have to invoke the plug-in function $('#RichUIControlID').richUIControlID().val() that will return a jQuery object with the necessary changes. val() does in this case what I want it to do.

However, if I could maintain the jQuery interface without that additional function call it would let me continue to use a familiar pattern which has tremendous reuse value in my case.

// I want to change val() depending on some property of the selector #RichUIControlID
$('#RichUIControlID').val()

Can it be done?

Edit 1:

One way to do this thanks to the link provided by mamoo, would be to do it like this then:

(function() {
    var val = jQuery.fn.val;
    jQuery.fn.val = function() {
        if (this.is('#RichUIControlID'))
            return this.richUIControlID().val()
        else
            return val.apply(this, arguments);
    }
})();

However, it feels a bit too intrusive. Every call to val() shouldn’t have to check if it’s the #RichUIControlID element, I’d rather hook this up during construction if possible.

Edit 2:

This is the stuff, browsing the source code it’s actually possible to take control of the jQuery constructor in the same manner. The caveat here is that if the first thing you do is not to forward the call to the default constructor, you’ll end up with a troublesome call stack.

(function() {
    var init = jQuery.fn.init;
    jQuery.fn.init = function() {
        var q = init.apply(this, arguments); // call this first
        if (q.data('RichUIControlID'))
            return q.richUIControlID();
        else
            return q;
    }
})();
  • 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-18T05:12:49+00:00Added an answer on May 18, 2026 at 5:12 am

    You can override a JQuery’s val() method (see http://www.bennadel.com/blog/1624-Ask-Ben-Overriding-Core-jQuery-Methods.htm) to implement your own logic, and leave a fallback to the original method if the target object is a standard one.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.