about widget client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 11:44 PM
I am using widget to create request button in record producer.
but when commit the data ,
I tried to use g_form.submit. but it seems nothing got committed.
ps: I got the g_form object by using 「var g_form = $scope.page.g_form;」
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 11:51 PM
BTW, I am client script for your reference:
api.controller=function($scope) {
/* widget controller */
var c = this;
c.uiAction = function(action) {
var flag = inputCheck(g_form);
if(action == 'confirm'){
//doSomething
}else if(action == 'apply' && flag){
g_form.submitted = true;
g_form.submit();
}
}
}
g_form.submitted = false;
}else if(action == 'apply' && checkResult){
g_form.submitted = true;
g_form.submit(); //it is not working properly here.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 11:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 12:03 AM
HTML:
<div class="panel panel-default">
<div class="panel-body" >
<button type="button" class="btn btn-primary" ng-click="c.uiAction('confirm')">確認</button>
<button type="button" class="btn btn-secondary" ng-click="c.uiAction('apply')">申請</button>
</div>
</div>
Client script:
api.controller=function($scope) {
/* widget controller */
var c = this;
c.uiAction = function(action) {
if ($scope.page.g_form) {
var g_form = $scope.page.g_form;
var flag = inputCheck(g_form,action);
}
}
function inputCheck(g_form,action) {
var checkResult = true;//this is a just a flg for test.
if(action == 'confirm'){
if(checkResult){
g_form.addInfoMessage('エラーがありません。');
}
g_form.submitted = false;
}else if(action == 'apply' && checkResult){
g_form.submitted = true;
g_form.submit();
}
return checkResult;
}
}
and I didn't set the Server side script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 12:07 AM
Hello @jieLian123
Try below code
api.controller = function($scope) {
/* widget controller */
var c = this;
c.uiAction = function(action) {
if ($scope.page && $scope.page.g_form) {
var g_form = $scope.page.g_form;
var flag = inputCheck(g_form, action);
}
};
function inputCheck(g_form, action) {
var checkResult = true; // Assuming this is a just a flg for test.
if (action == 'confirm') {
if (checkResult) {
g_form.addInfoMessage('エラーがありません。');
}
g_form.submitted = false;
} else if (action == 'apply' && checkResult) {
g_form.submitted = true;
g_form.submit();
}
return checkResult;
}
};