MyBB Community Forums

Full Version: Bootstrap button does not show counter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I modified my forumdisplay_inlinemoderation template so that the button with the counter becomes

<button type="submit" class="btn btn-primary" name="go" value="{$lang->inline_go} ({$inlinecount})" id="inline_go">{$lang->inline_go} ({$inlinecount})</button>

The original button code is:

<input type="submit" class="button" name="go" value="{$lang->inline_go} ({$inlinecount})" id="inline_go">

The button works properly except the counter does not increment when threads are selected. Any idea on how to fix?
snipped
The best thing you can do is to wrap Like/Liked text into one more span and give it a class:

<button class="btn btn-sm btn-default like-btn active" type="button" id="10">
   <span class="glyphicon glyphicon-thumbs-up"></span>
   <span class="text">Liked</span>
   <span class="badge like-badge">1</span>
</button>
It will simplify code:

$(document).on("click", ".like-btn", function(e) {
   e.preventDefault();

   var $label = $(this).find('.text'),
       $badge = $(this).find('.badge'),
       count = Number($badge.text()),
       active = $(this).hasClass('active');

   $label.text(active ? 'Like' : 'Liked');
   $badge.text(active ? count - 1 : count + 1);
   $(this).toggleClass('active');
});
Try:

<input type="submit" class="btn btn-danger" name="go" value="Go (0)" id="inline_go">
(2015-11-02, 08:04 AM)dwarak Wrote: [ -> ]The best thing you can do is to wrap Like/Liked text into one more span and give it a class:

<button class="btn btn-sm btn-default like-btn active" type="button" id="10">
   <span class="glyphicon glyphicon-thumbs-up"></span>
   <span class="text">Liked</span>
   <span class="badge like-badge">1</span>
</button>
It will simplify code:

$(document).on("click", ".like-btn", function(e) {
   e.preventDefault();

   var $label = $(this).find('.text'),
       $badge = $(this).find('.badge'),
       count = Number($badge.text()),
       active = $(this).hasClass('active');

   $label.text(active ? 'Like' : 'Liked');
   $badge.text(active ? count - 1 : count + 1);
   $(this).toggleClass('active');
});

Java training in chennai  | Android training in chennai  | Software Testing Training in Chennai

Still have to give this a try

(2015-11-02, 08:44 AM)Leefish Wrote: [ -> ]Try:

<input type="submit" class="btn btn-danger" name="go" value="Go (0)" id="inline_go">

This don't work, the counter still does not increment.
Works fine for me on DFS. have you bust the js? Big Grin


It has to be an input - that is what the js looks for.


<input type="submit" class="btn btn-danger" name="go" value="{$lang->inline_go} ({$inlinecount})" id="inline_go">
O yeah, now it works! I had it with <button> instead of <input> Thanks for that!