Skip to content

Instantly share code, notes, and snippets.

@jackkitley
Created March 28, 2013 08:49
Show Gist options
  • Save jackkitley/5261700 to your computer and use it in GitHub Desktop.
Save jackkitley/5261700 to your computer and use it in GitHub Desktop.
var clickedsectionelement;
function noteDamage(el)
{
var data = $('#damage-form').serializeArray();
data = data.concat({'name':'vehicletypedamageareaid', 'value':el.vehicletypedamageareaid},
{'name':'vehicleid', 'value':<?= $vehicleid?>});
<?php echo CHtml::ajax(array(
'url'=>array('vehicle/DamageForm'),
'data'=> "js:data",
'type'=>'post',
'dataType'=>'json',
'success'=>"function(data)
{
if (data.status == 'failure') {
$('#dialog-damage div.divForForm').html(data.div);
// Here is the trick: on submit-> once again this function!
$('#dialog-damage div.divForForm form').submit(noteDamage);
}else {
if(data.entrystatus == 'new') {
clickedsectionelement.checked = 'true';
clickedsectionelement.attr({fill:clickedsectionelement.paper.on_areacolor,opacity:0.8});
}else if(data.entrystatus == 'delete') {
clickedsectionelement.checked = 'false';
clickedsectionelement.attr({fill:clickedsectionelement.paper.off_areacolor,opacity:0.5});
}
$('#dialog-damage div.divForForm').html(data.div);
setTimeout(\"$('#dialog-damage').dialog('close') \",1000);
}
} ",
))?>;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment