Skip to content

Commit

Permalink
Dev: trigger click on save button
Browse files Browse the repository at this point in the history
when the save button is clicked, now, it's triggering a click on the hidden submit button, so all the javascript control and the html5 input constraints are respected.
  • Loading branch information
LouisGac committed Oct 9, 2015
1 parent 32e08c4 commit c94fb2a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions scripts/admin/admin_core.js
Expand Up @@ -46,7 +46,7 @@ $(document).ready(function(){
}
doToolTip();
$('.btntooltip').tooltip();

$('button,input[type=submit],input[type=button],input[type=reset],.button').button();
$('button,input[type=submit],input[type=button],input[type=reset],.button').addClass("limebutton");

Expand All @@ -68,7 +68,7 @@ $(document).ready(function(){
$("#save-form-button").on('click', function(){
var formid = '#'+$(this).attr('aria-data-form-id');
$form = $(formid);
$form.find('[type="submit"]').trigger('click');;
$form.find('[type="submit"]').trigger('click');
});
}

Expand Down Expand Up @@ -96,14 +96,15 @@ $(document).ready(function(){
}
return $form;
};

if ($('#save-button').length > 0){
$('#save-button').on('click', function()
{
var $form = getForm(this);
closeAfterSaveInput.val("false");
$form.append(closeAfterSaveInput);
$form.submit();
$form.find('[type="submit"]').trigger('click');;
//$form.submit();
});
}

Expand All @@ -125,10 +126,10 @@ $(document).ready(function(){
$('#question-preview').modal('show');
});
}

if ($('#advancedquestionsettingswrapper').length>0){
updatequestionattributes();
}
}

/* Switch format group */
if ($('#switchchangeformat').length>0){
Expand All @@ -138,16 +139,16 @@ $(document).ready(function(){
$.ajax({
url : $url,
type : 'GET',
dataType : 'html',
dataType : 'html',

// html contains the buttons
success : function(html, statut){
},
error : function(html, statut){
alert('error');
}
});

});
};

Expand All @@ -160,7 +161,7 @@ $(document).ready(function(){
});

});

$('#hideadvancedattributes').click(function(){
$('#showadvancedattributes').show();
$('#hideadvancedattributes').hide();
Expand Down Expand Up @@ -241,13 +242,13 @@ function qTypeDropdownInit()
});
});
$(document).ready(function() {

$('.questionType').on('mouseenter', function(e){
//alert($(this).attr('class'));
$('.questionType').qtip('hide');
$(this).qtip('option', 'position.target', $(this).qtip('show'));
});

$('.questionType').on('mouseleave', function(e){
$(this).qtip('hide');
});
Expand All @@ -263,8 +264,8 @@ function qTypeDropdownInit()
{
$($(e.currentTarget).data().select2Data.element).qtip('hide');
}
});
$('#question_type').on('close', function(e) {
$('#question_type option').qtip('hide');
Expand Down Expand Up @@ -390,7 +391,7 @@ function doToolTip()
}
});
$("a > img[alt]").data("hasqtip", true ).removeAttr('title');

// Call the popuptip hover rel attribute
$('.popuptip').each(function(){
if($(this).attr('rel')){
Expand Down Expand Up @@ -818,7 +819,7 @@ if ('ab'.substr(-1) != 'b') {
}

/**
* Yii CSRF protection divs breaks this script so this function moves the
* Yii CSRF protection divs breaks this script so this function moves the
* hidden CSRF field out of the div and remove it if needed
* 140207 : Why this function is needed ? Where is the script broken ?
*/
Expand Down Expand Up @@ -875,7 +876,7 @@ function initializeAjaxProgress()
});
$('#ajaxprogress').bind('ajaxStop', function()
{

$(this).dialog('close');
});
}
Expand Down Expand Up @@ -927,7 +928,7 @@ function addHiddenElement(theform,thename,thevalue)
myel.value = thevalue;
return myel;
}
function onlyUnique(value, index, self) {
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}

Expand Down

0 comments on commit c94fb2a

Please sign in to comment.