* Install a click handler to switch to edit mode when the
* edit button is pressed.
*/
- $(".richtext_doedit").click(function (event) {
+ $(".richtext_doedit").click(function () {
var editor = $(this).parents(".richtext_container").find("textarea");
var preview = $(this).parents(".richtext_container").find(".richtext_preview");
$(this).siblings(".richtext_dopreview").prop("disabled", false);
$(this).prop("disabled", true);
-
- event.preventDefault();
});
/*
* Install a click handler to switch to preview mode when the
* preview button is pressed.
*/
- $(".richtext_dopreview").click(function (event) {
+ $(".richtext_dopreview").click(function () {
var editor = $(this).parents(".richtext_container").find("textarea");
var preview = $(this).parents(".richtext_container").find(".richtext_preview");
var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
$(this).siblings(".richtext_doedit").prop("disabled", false);
$(this).prop("disabled", true);
-
- event.preventDefault();
});
});
<div class="card bg-body-tertiary h-100">
<div class="card-body">
<%= render :partial => "shared/#{type}_help" %>
- <%= submit_tag t(".edit"), :id => "#{id}_doedit", :class => "richtext_doedit btn btn-primary", :disabled => true %>
- <%= submit_tag t(".preview"), :id => "#{id}_dopreview", :class => "richtext_dopreview btn btn-primary" %>
+ <%= button_tag t(".edit"), :type => "button", :id => "#{id}_doedit", :class => "richtext_doedit btn btn-primary", :disabled => true %>
+ <%= button_tag t(".preview"), :type => "button", :id => "#{id}_dopreview", :class => "richtext_dopreview btn btn-primary" %>
</div>
</div>
</div>
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
assert_select "input[name=commit][type=submit][value=Publish]", :count => 1
- assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
- assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
- assert_select "input", :count => 6
+ assert_select "button[type=button]", :text => "Edit", :count => 1
+ assert_select "button[type=button]", :text => "Preview", :count => 1
+ assert_select "input", :count => 4
end
end
end
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
assert_select "input[name=commit][type=submit][value=Update]", :count => 1
- assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
- assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
- assert_select "input", :count => 7
+ assert_select "button[type=button]", :text => "Edit", :count => 1
+ assert_select "button[type=button]", :text => "Preview", :count => 1
+ assert_select "input", :count => 5
end
end