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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:45:56+00:00 2026-05-17T23:45:56+00:00

Here I have a widget and I want to call a function once #slider.slider();

  • 0

Here I have a widget and I want to call a function once #slider.slider();. what is the code?

$( "#slider" ).slider({  

    //initial function here.
    alert("A");

    value: 50,
    slide: function(event, ui) {
           displaySlideValue();
    }

});
  • 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-17T23:45:57+00:00Added an answer on May 17, 2026 at 11:45 pm

    Why not just do

    $('#slider').slider({ ... }).each(function() { /* your code here */ });
    

    Alternatively you could wrap the .slider() call in your own mini-extension:

    $.fn.sliderWithInit = function(params, init) {
      return this.slider(params).each(init);
    });
    

    then you could say

    $('#slider').sliderWithInit({ /* params */ }, function() { /* init code */ });
    

    Obviously “slider” could be made generic:

    $.wrapWithInit = function(widgetName) {
      $.fn[widgetName + 'WithInit'] = function(params, init) {
        return this[widgetName](params).each(init);
      });
    });
    

    Then you can do it for “dialog” for example:

    $.wrapWithInit('dialog');
    $('#dialog').dialogWithInit({ /* dialog params */ }, function() { /* init code */ });
    

    As @mikerobi points out, it’s not 100% clear when you want your initialization function to be called. Most widgets have an “onFoo” type callback that’s called when the widget is activated (whatever that means for the given widget). If you just want to initialize on the first call, you could just make the callback be a closure that keeps track of whether it’s ever done the initialization work. If it detects it’s already done it, it would just return.

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

Sidebar

Related Questions

Here I have piece of code, showing example of how I want to update
Here is the situation, i have a widget containing two text views and i
I have 2 questions to ask here. I am refering http://www.broculos.net/en/article/android-101-how-create-stackview-widget to create a
OK Stackoverflowians, Here's the riddle for the day. I have a weather sidebar widget
Here I have declared another virtual function in Derived class. #include <iostream> using namespace
I have a 4x4 widget and i want to update a little piece of
Hi i have two tabs in my tab widget,i want to apply the two
I have created the widget in Jquery mobile for Tabs. I want that when
I have a function in jQuery and I want that where that function is
i have two functions and one of them call the other one. I want

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.