I'm trying to change the text of a button, but I'm unable to do it.
$( function() {
$('.btn').on('click', function(automated_campagin_hash) {
var $this = $(this);
$this.button('loading');
var automated_campagin_hash = $this.data('campaign-automated-hash');
var url = "/automated-campaigns/change_status/" + String(automated_campagin_hash);
$.get( url , function( data ) {
console.log(data);
$this.button('reset');
$this.removeClass("btn-danger").addClass("btn-info");
$this.html('Activated');
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<button type="button" class="btn btn-danger btn" id="load" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i>" data-campaign-automated-hash="<%= automated_campaigns[i].automated_campaign_hash %>">Desativar</button>