------------------------------------------------------------ revno: 7061 committer: Hieu <hieu.hispviet...@gmail.com> branch nick: dhis2 timestamp: Mon 2012-05-28 17:23:05 +0700 message: local vn - Fixed bug while loading form by event and code style. modified: local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js' --- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js 2012-05-28 08:09:58 +0000 +++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js 2012-05-28 10:23:05 +0000 @@ -343,6 +343,9 @@ clearListById( 'selectedPeriodId' ); hideById('attributeDiv'); + $( '#valueInput' ).unbind( 'change' ); + $( '#value' ).unbind( 'select' ); + $( '#selectedPeriodId' ).unbind( 'change' ); $( '#selectedPeriodId' ).removeAttr( 'disabled' ); $( '#prevButton' ).removeAttr( 'disabled' ); $( '#nextButton' ).removeAttr( 'disabled' ); @@ -387,9 +390,10 @@ }, function( json ) { - if( json.department.length > 0 ) + clearListById( 'subDataSetId' ); + + if ( json.department.length > 0 ) { - clearListById( 'subDataSetId' ); $('#subDataSetId').append('<option value=-1>' + i18n_please_select_department + '</option>'); for ( i in json.department ) { @@ -397,12 +401,11 @@ } byId( 'inputCriteria' ).style.width = '840px'; - showById('departmentTitleDiv'); - showById('departmentDiv'); + showById( 'departmentTitleDiv' ); + showById( 'departmentDiv' ); - jQuery("#valueInput").unbind('change'); - jQuery("#value").unbind('select'); - jQuery('#selectedPeriodId').bind('change', periodSelected); + jQuery( '#valueInput' ).unbind( 'change' ); + jQuery( '#value' ).unbind( 'select' ); } else { @@ -412,41 +415,43 @@ hideById('departmentTitleDiv'); hideById('departmentDiv'); } + + jQuery( '#selectedPeriodId' ).bind( 'change', periodSelected ); } ); } function loadAttributeValues( dataSetId ) { $.getJSON( 'loadAttribueValues.action', - { - dataSetId: dataSetId - } - , function( json ) - { - if( json.attributeValues.length > 0 ) - { - clearListById( 'value' ); - for ( i in json.attributeValues ) - { - $('#value').append('<option value="' + json.attributeValues[i] + '">' + json.attributeValues[i] + '</option>'); - } - - autoCompletedField(); - - jQuery("#valueInput").bind('change', periodSelected('bind change')); - jQuery("#value").bind('select', periodSelected('bind select')); - - showById('attributeDiv'); - } - else - { - jQuery("#valueInput").unbind('change'); - jQuery("#value").unbind('select'); - hideById('attributeDiv'); - } + { + dataSetId: dataSetId + } + , function( json ) + { + clearListById( 'value' ); + + if( json.attributeValues.length > 0 ) + { + for ( i in json.attributeValues ) + { + jQuery( '#value' ).append( '<option value="' + json.attributeValues[i] + '">' + json.attributeValues[i] + '</option>' ); + } + + autoCompletedField(); + + jQuery( '#valueInput' ).bind( 'change', periodSelected() ); + jQuery( '#value' ).bind( 'select', periodSelected() ); - jQuery('#selectedPeriodId').bind('change', periodSelected); - } ); + showById( 'attributeDiv' ); + } + else + { + jQuery( '#valueInput' ).unbind( 'change' ); + jQuery( '#value' ).unbind( 'select' ); + + hideById( 'attributeDiv' ); + } + } ); } // ----------------------------------------------------------------------------- @@ -480,16 +485,21 @@ $( '#currentPeriod' ).html( periodName ); - var periodId = $( '#selectedPeriodId' ).val(); + var periodId = getFieldValue( 'selectedPeriodId' ); if ( periodId && periodId != -1 ) { - if ( hasElements( 'subDataSetId' ) && getFieldValue( 'subDataSetId' ) == null ) { + if ( hasElements( 'subDataSetId' ) && getFieldValue( 'subDataSetId' ) == null ) + { return; - } else { - showLoader(); - loadForm( dataSetId, getFieldValue( 'valueInput' ) ); - } + } + else if ( getFieldValue( 'subDataSetId' ) ) + { + dataSetId = $( '#subDataSetId option:selected' ).val(); + } + + showLoader(); + loadForm( dataSetId, getFieldValue( 'valueInput' ) ); } else {
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp