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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:17:58+00:00 2026-06-02T16:17:58+00:00

I am using twitter Bootstrap with jQuery and i was wondering how can i

  • 0

I am using twitter Bootstrap with jQuery

and i was wondering how can i toggle between “Subscribe / UnSubscribe”

Each click its an ajax request so the user can Subscribe / UnSubscribe

Once a user subscribed i display a messege “Subscribed!”
What about if a user regret and want to unubscribed?

I would like to have in one button both functionality.
I am changing the id dynamically but it doent work!

button class="btn" id="subscribe" data-toggle="button" data-loading-text="Loading..."  data-complete-text="Subscribed!">Subscribe
$(document).ready(function () {
        $('#subscribe').button();
        $('#unsubscribe').button();
    });




    $('#unsubscribe').click(function () {   
        $('#unsubscribe').button('loading');

        $.ajax({
            url: "<%= "#{root_url}unsubscribe_from/#{@collection.id}"%>" ,
            type: "GET",
            data: "",
            success: function(data) {
                $('#unsubscribe').button('complete');
                jQuery("#unsubscribe").attr("id","subscribe");
                jQuery("#subscribe").attr("data-complete-text").text("Subscribed!");
                }});
                return false;

            });


$('#subscribe').click(function () {   
    $('#subscribe').button('loading');
    // $('#subscribe').button('reset');
    $.ajax({
        url: "<%= "#{root_url}subscribe_to/#{@collection.id}"%>" ,
        type: "GET",
        data: "",
        success: function(data) {
            $('#subscribe').button('complete');
            jQuery("#subscribe").attr("id","unsubscribe");
            jQuery("#unsubscribe").attr("data-complete-text").text("Unsubscribe!");
            }});
            return false;

        });
  • 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-02T16:17:59+00:00Added an answer on June 2, 2026 at 4:17 pm
    $(document).on('click', '#subscribe, #unsubscribe', function(){
        var url; 
        var button_id; 
        var button_text; 
        var self = $(this);  
        self.button('loading');
    
       if( this.id === 'subscribe' )
        {
            url = "<%= "#{root_url}subscribe_to/#{@collection.id}"%>"; 
            button_id = 'unsubscribe';
            button_text = 'Subscribed!';  
        }
        else 
        {
            url = "<%= "#{root_url}unsubscribe_from/#{@collection.id}"%>"; 
            button_id = 'subscribe'; 
            button_text = 'Unsubscribed!'; 
        }
    
          $.ajax({
            url: url,
            type: "GET",
            data: "",
            success: function(data) {
                   self.button('complete');
                   self.attr("id", button_id);
                   self.attr("data-complete-text", button_text).text(button_text);
                }});
                return false;
    
          });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just integrated my design built using twitter bootstrap, html5, css, jquery with
I'm using Twitter Bootstrap with Django to render forms. Bootstrap can format your forms
I have a Google Chrome extension that opens a Twitter Bootstrap dialog (using JQuery
I'm using jQuery UI 1.8.19 and Twitter Bootstrap 2.0.3 in a site I'm developing.
How can I get the geolocation of each user's tweets? Using twitter API. Any
I am using twitter bootstrap for a project - in particular its tab functions
I've been checking/using Twitter Bootstrap for quite a while now. I like what they've
I'm using twitter bootstrap tabs and i want to load only the CSS needed
I'm using Twitter Bootstrap. The alert HTML code is: <div class=alert alert-block> <a class=close
I am using Twitter Bootstrap in my rails app. My navbar looks perfect in

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.