Skip to main content

Disable Button from a link by ajax

example -1
<% if @contest.extension_status == 'pending' %>
  <li><%= link_to 'Extend Contest', admin_extend_contest_path(id: @contest.id), {:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window', title: "Extend Contest",id: "extend_contest_link"} %></li>
<% elsif @contest.extension_status == 'complete' %>
  <li><%= link_to 'Alredy Extended', '#',title: "Alredy Extended", class: 'disabled' %></li>

<% else %>

<script>

$('#refund_contest a').addClass('disabled');
$('#refund_contest a').text('Refunded');
$('#refund_contest a').attr('href', '#');

$('.status').text('closed');

</script>

Comments

Popular posts from this blog

Undefined method `stringify_keys' for " ": String

<%= link_to 'NAME_OF_LINK ', URL_OF_LINK_path, class: "XXX", remote: true do %>      #here comes wrapping code  <% end %> This gives error of  Undefined method `stringify_keys'  for " ": String,  Reason being :-   its not good practice to write NAME_OF_LINK,  with link_to .. do   block Typically this is used when you want to have images or other tags as the contents of the link. It's purely for display purposes  here i have given few examples for ............

Set Hidden field value by "onclick" - jquery

sometime we have some data to send with onclick function , in genral onclick event function works like this:- $('id or class').on("click", function(){   // codes goes here }); here is example of call onclick function on any link, or div:- example -1  <input type="radio" id="1_star<%= val %>" name="rating<%= val %>" value="5" onclick = "set_rating(this,'<%= val %>');"/>     <%= vote.hidden_field :rating, value: "", id: "rating_param_#{val}" %>    <script type="text/javascript>       function set_rating(elem, application_id){          //code goes here          $('#rating_param_'+ application_id).get(0).value = rating;        };       // ajax request          $.ajax({       url: "/admin/dashboard/show_tickets",       type: "GET", ...