diff --git a/application/controllers/admin/questions.php b/application/controllers/admin/questions.php index a9b03b82362..9997735db80 100644 --- a/application/controllers/admin/questions.php +++ b/application/controllers/admin/questions.php @@ -982,6 +982,7 @@ public function ajaxlabelsetdetails() $criteria->order='sortorder'; $labelsdata=Label::model()->findAll($criteria); $i=0; + $data=array(); foreach($labelsdata as $labeldata) { $data[$i]['lid'] = $labeldata->lid; @@ -996,7 +997,7 @@ public function ajaxlabelsetdetails() //$labels=dbExecuteAssoc($query); //Label::model()->find(array('lid' => $lid, 'language' => $language), array('order' => 'sortorder')); //$connect->GetArray($query); $resultdata[]=array($language=>array($labels,getLanguageNameFromCode($language,false))); } - + header('Content-type: application/json'); echo ls_json_encode($resultdata); } @@ -1019,6 +1020,7 @@ public function ajaxlabelsetpicker() $language=null; } $resultdata=getlabelsets($language); + header('Content-type: application/json'); echo ls_json_encode($resultdata); } diff --git a/scripts/admin/subquestions.js b/scripts/admin/subquestions.js index c10aeb41984..4f6b813d5ab 100644 --- a/scripts/admin/subquestions.js +++ b/scripts/admin/subquestions.js @@ -2,18 +2,18 @@ var labelcache=[]; $(document).ready(function(){ removeCSRFDivs(); - $("body").delegate(".code", "keypress", function(e) { - key=e.which; - if ( key==null || key==0 || key==8 || key==9 || key==27 ) - return true; - thischar=String.fromCharCode(key); - returnvalue=(thischar==thischar.replace(/[^a-zA-Z0-9_]/,'')); - return returnvalue; - }); - $("body").delegate(".code", "keyup", function() { - if ($(this).val().replace(/[^a-zA-Z0-9_]/,'')!=$(this).val()) - $(this).val($(this).val().replace(/[^a-zA-Z0-9_]/,'')); - }); +// $("body").delegate(".code", "keypress", function(e) { +// key=e.which; +// if ( key==null || key==0 || key==8 || key==9 || key==27 ) +// return true; +// thischar=String.fromCharCode(key); +// returnvalue=(thischar==thischar.replace(/[^a-zA-Z0-9_]/,'')); +// return returnvalue; +// }); +// $("body").delegate(".code", "keyup", function() { +// if ($(this).val().replace(/[^a-zA-Z0-9_]/,'')!=$(this).val()) +// $(this).val($(this).val().replace(/[^a-zA-Z0-9_]/,'')); +// }); $('.tab-page:first .answertable tbody').sortable({ containment:'parent', start:startmove, update:aftermove, @@ -70,7 +70,6 @@ $(document).ready(function(){ function deleteinput() { - // 1.) Check if there is at least one answe countanswers=$(this).closest("tbody").children("tr").length;//Maybe use class is better if (countanswers>1) @@ -83,7 +82,7 @@ function deleteinput() var x; for (x in languages) - { + { tablerow=$('#answertable_'+languages[x]+'_'+scale_id+' tbody tr:nth-child('+index+')'); if (x==0) { tablerow.fadeTo(400, 0, function(){ @@ -95,8 +94,11 @@ function deleteinput() tablerow.remove(); } } - rowinfo=tablerow.attr('id').split('_'); - $('#deletedqids').val($('#deletedqids').val()+' '+rowinfo[2]); + if ($(tablerow).is('[id]')) + { + rowinfo=$(tablerow).attr('id').split('_'); + $('#deletedqids').val($('#deletedqids').val()+' '+rowinfo[2]); + } } else { @@ -127,7 +129,7 @@ function addinput() tablerow=$('#answertable_'+languages[x]+'_'+scale_id+' tbody tr:nth-child('+newposition+')'); var randomid='new'+Math.floor(Math.random()*111111) if (x==0) { - inserthtml='
' + inserthtml=' ' } else { @@ -284,28 +286,28 @@ function lsbrowser() var x=0; $("#labelsets").removeOption(/.*/); for (x in json) - { + { $('#labelsets').addOption(json[x][0],json[x][1]); if (x==0){ remind=json[x][0]; } } if ($('#labelsets > option').size()>0) - { + { $('#labelsets').selectOptions(remind); lspreview(); $('#btnlsreplace').removeClass('ui-state-disabled'); $('#btnlsinsert').removeClass('ui-state-disabled'); - $('#btnlsreplace').attr('disabled',''); - $('#btnlsinsert').attr('disabled',''); + $('#btnlsreplace').removeProp('disabled'); + $('#btnlsinsert').removeProp('disabled'); } else - { + { $("#labelsetpreview").html(" "); $('#btnlsreplace').addClass('ui-state-disabled'); $('#btnlsinsert').addClass('ui-state-disabled'); - $('#btnlsreplace').attr('disabled','disabled'); - $('#btnlsinsert').attr('disabled','disabled'); + $('#btnlsreplace').prop( "disabled", true ); + $('#btnlsinsert').prop( "disabled", true ); } }); @@ -315,7 +317,7 @@ function lsbrowser() function lspreview() { if ($('#labelsets > option').size()==0) - { + { return; } @@ -330,7 +332,7 @@ function lspreview() data: {lid:lsid, sid:surveyid}, cache: true, success: function(json){ - $("#labelsetpreview").tabs('destroy'); + //$("#labelsetpreview").tabs('destroy'); $("#labelsetpreview").empty(); var tabindex=''; var tabbody=''; @@ -364,15 +366,17 @@ function lspreview() $("#labelsetpreview").append('