[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8101] Made a check for AJAX call for choosing proced
From: |
Torstein |
Subject: |
[Fmsystem-commits] [8101] Made a check for AJAX call for choosing procedures based on control area. |
Date: |
Mon, 14 Nov 2011 10:18:18 +0000 |
Revision: 8101
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8101
Author: vator
Date: 2011-11-14 10:18:17 +0000 (Mon, 14 Nov 2011)
Log Message:
-----------
Made a check for AJAX call for choosing procedures based on control area.
Message "Ingen prosedyrer" is shown when there doin't exists any prosedures for
control area.
Modified Paths:
--------------
trunk/controller/inc/class.uiprocedure.inc.php
trunk/controller/js/controller/ajax.js
Modified: trunk/controller/inc/class.uiprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.uiprocedure.inc.php 2011-11-14 09:55:07 UTC
(rev 8100)
+++ trunk/controller/inc/class.uiprocedure.inc.php 2011-11-14 10:18:17 UTC
(rev 8101)
@@ -290,7 +290,10 @@
$procedures_array =
$this->so->get_procedures_by_control_area_id($control_area_id);
- return json_encode( $procedures_array );
+ if(count($procedures_array)>0)
+ return json_encode( $procedures_array );
+ else
+ return null;
}
Modified: trunk/controller/js/controller/ajax.js
===================================================================
--- trunk/controller/js/controller/ajax.js 2011-11-14 09:55:07 UTC (rev
8100)
+++ trunk/controller/js/controller/ajax.js 2011-11-14 10:18:17 UTC (rev
8101)
@@ -1,28 +1,34 @@
$(document).ready(function(){
-
-
- // When control area is chosen in control.xsl select procedure is
populated
+ // Control.xsl when control area is selected procedures related to
control area is fetched form db
+ // and procedure select list is populated
$("#control_area_id option").click(function () {
var control_area_id = $(this).val();
var requestUrl =
"index.php?menuaction=controller.uiprocedure.get_procedures&phpgw_return_as=json"
+ var htmlString = "";
+
$.ajax({
type: 'POST',
dataType: 'json',
url: requestUrl + "&control_area_id=" +
control_area_id,
success: function(data) {
- var obj = jQuery.parseJSON(data);
- var htmlString = "";
-
- $.each(obj, function(i) {
- htmlString += "<option value='" +
obj[i].id + "'>" + obj[i].title + "</option>";
- });
-
- $("#procedure_id").html( htmlString );
- }
+ if( data != null){
+ var obj = jQuery.parseJSON(data);
+
+ $.each(obj, function(i) {
+ htmlString += "<option
value='" + obj[i].id + "'>" + obj[i].title + "</option>";
+ });
+
+ $("#procedure_id").html( htmlString );
+ }
+ else
+ {
+ htmlString += "<option>Ingen
prosedyrer</option>"
+ $("#procedure_id").html( htmlString
);
+ }
+ }
});
-
});
// Saves order of control items for a group
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8101] Made a check for AJAX call for choosing procedures based on control area.,
Torstein <=