Permalink
Browse files

feature(thewire): allow multiple add forms to exist on the same page

  • Loading branch information...
jdalsem committed Mar 17, 2016
1 parent 094ce5c commit 9f72e2874912d50c917b466a8a4ac2f512f69aa2
Showing with 6 additions and 5 deletions.
  1. +6 −5 mod/thewire/views/default/thewire.js
@@ -7,7 +7,7 @@ elgg.thewire.init = function() {
var callback = function() {
var maxLength = $(this).data('max-length');
if (maxLength) {
elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), maxLength);
elgg.thewire.textCounter(this, $(this).closest('form').find("#thewire-characters-remaining span"), maxLength);
}
};
@@ -27,15 +27,16 @@ elgg.thewire.textCounter = function(textarea, status, limit) {
var remaining_chars = limit - $(textarea).val().length;
status.html(remaining_chars);
var $submit = $(textarea).closest('form').find('#thewire-submit-button');
if (remaining_chars < 0) {
status.parent().addClass("thewire-characters-remaining-warning");
$("#thewire-submit-button").attr('disabled', 'disabled');
$("#thewire-submit-button").addClass('elgg-state-disabled');
$submit.attr('disabled', 'disabled');
$submit.addClass('elgg-state-disabled');
} else {
status.parent().removeClass("thewire-characters-remaining-warning");
$("#thewire-submit-button").removeAttr('disabled', 'disabled');
$("#thewire-submit-button").removeClass('elgg-state-disabled');
$submit.removeAttr('disabled', 'disabled');
$submit.removeClass('elgg-state-disabled');
}
};

0 comments on commit 9f72e28

Please sign in to comment.