javascript - Jquery won't save rest of the row -



javascript - Jquery won't save rest of the row -

this js code

var route = new function () { var oglobal = this; this.ssaveurl = ''; this.setsaveurl = function (_surl) { this.ssaveurl = _surl; } this.seteventsubmit = function () { $('[id^="route_update"]').each(function () { $(this).click(function () { var odata = $(this).closest('tr').find('input').serializearray(); var orow = $(this).closest('tr'); console.log(odata); oreq = $.post(oglobal.ssaveurl, odata, function (data) { if (data['valid'] != "true") { //console.log('error'); //fade in orow.closest('#comment').html('error').css('display', 'block').fadein(1000); //fade out settimeout(function () { $('#comment').html('').fadeout(1000); }, 1500); //fade in $('#comment') } else { //console.log('success'); //fade in $('#comment').html('insert success').fadein(1000); //fade out settimeout(function () { $('#comment').html('').fadeout(1000); }, 1500); //fade in $('#comment') } homecoming false; }, 'json'); homecoming false; }); }); } this.init = function () { this.seteventsubmit(); } }

don't know why have 2 problems: -the submit message (success or error) displayed on first row -it saves first collumn of row , leaves others blank if before there datas

this html

<form class="form-inline" role="form"> <form class="well form-inline"> <table class="table table-bordered" width="100%"> <tr> <th width="13%">path</th> <th width="13%">module</th> <th width="13%">controller</th> <th width="13%">action</th> <th width="13%">access role</th> <th width="13%">compare operator</th> <th width="9%">submit</th> </tr> <? $aroutes = $this->getvalue('aroutes'); if( count($aroutes) == 0 ) { ?> <tr> <td colspan="7">no routes found!</td> </tr> <? } else { /** * @var default_model_routeentity $oroute */ foreach ( $aroutes $oroute) { ?> <tr> <td width="13%"> <input type="text" name="path" value="<?= $oroute->getpath(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oroute->getmodule(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oroute->getcontroller(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oroute->getaction(); ?>"/> </td> <td width="13%"> <input type="text" class="form-actions" value="<?= $oroute->getaccessrole(); ?>"/> </td> <td width="13%"> <input type="text" value="<?= $oroute->getrolecompareoperator(); ?>"/> </td> <td width="9%"> <input type="hidden" name="id" value="<?= $oroute->getid(); ?>" /> <button type="button" class="btn btn-default btn-sm" id="route_update">edit</button> <div id="comment" style="display: none;"></div> </td> </tr> <? } } ?> </table> </form> </form> <? $this->addjs('admin/cms/route'); ?> <script type="text/javascript"> $(document).ready(function () { route.setsaveurl('<?=iv_url_base::url( 'admin_cms_routeupdate' ); ?>'); route.init(); }); </script>

and controller

public function routeupdateaction() { $iroute = iv_http_base::getparameter('id', iv_http_base::http_post); $spath = iv_http_base::getparameter('path', iv_http_base::http_post); $smodule = iv_http_base::getparameter('module', iv_http_base::http_post); $scontroller = iv_http_base::getparameter('controller', iv_http_base::http_post); $saction = iv_http_base::getparameter('action', iv_http_base::http_post); $iaccessrole = iv_http_base::getparameter('accessrole', iv_http_base::http_post); $irolecompareoperator = iv_http_base::getparameter('rolecompareoperator', iv_http_base::http_post); $oroute = default_model_routeentity::getinstancebyid($iroute); if (is_object($oroute) && $oroute instanceof default_model_routeentity) { $oroute->setpath($spath); $oroute->setmodule($smodule); $oroute->setcontroller($scontroller); $oroute->setaction($saction); $oroute->setaccessrole($iaccessrole); $oroute->setrolecompareoperator($irolecompareoperator); $oroute->save(); $areturn = array('valid' => 'true'); } else { $areturn = array('valid' => 'false'); } echo json_encode($areturn); } }

what wrong?

javascript php jquery

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -