Auto-fill current time for postdate field on new active page
The postdate datetime field was left blank on the "new" active creation page because orbit_form_helper.rb intentionally clears :new_record fields regardless of the model's :default value. Add inline JS (mirroring the pattern used in announcement-test) to fill act[postdate] with the current date/time only when the URL path ends in "new", so existing records are not overwritten on edit.
This commit is contained in:
parent
19b4b6f978
commit
806bb862c2
|
|
@ -404,6 +404,12 @@
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
if (location.pathname.substr(-3)=='new'){
|
||||||
|
var getDate = new Date();
|
||||||
|
function appendZero(n){ return n < 10 ? '0'+n : n; }
|
||||||
|
var toDay = getDate.getFullYear()+"/"+appendZero(getDate.getMonth()+1)+"/"+appendZero(getDate.getDate())+" "+appendZero(getDate.getHours())+":"+appendZero(getDate.getMinutes());
|
||||||
|
$('input[name="act[postdate]"]').val(toDay);
|
||||||
|
}
|
||||||
$("#act_is_top").parent().on("click",function(){
|
$("#act_is_top").parent().on("click",function(){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if($("#act_is_top").parent().hasClass("active")){
|
if($("#act_is_top").parent().hasClass("active")){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue