- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2015 02:23 AM
Hello.
I'm trying to Retrieve value from calendar to variable.
the calendar object is this:
<g:ui_date class="form-control" name="end_date" id="end_date" />
and the jelly syntax that supposed to retrieve the value into jvar_max variable is this:
<g:evaluate jelly="true" var="jvar_max">
var date =gel('end_date').value;
date;
</g:evaluate>
I've also tried this:
<g:evaluate jelly="true" var="jvar_max">
var date =document.getElementById('end_date').value;;
date;
</g:evaluate>
But still, every time that i send jvar_max into angular function it's alerted as "null"
<form ng-submit="updateRecordList('${jvar_max}')" >
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2015 09:37 AM
Hi.
I've tried all of your suggestion' but nothing seems to work.
eventually i used this o the custom element on ui page:
<g:ui_date_custom title="date_pick" class="date-picker"
name="start_date_row1" id="start_date_row1" ng-model="numbers" value = "${gs.now()}" onchange="angular.element(this).scope().onload()"/>
I've created the element with the help of the post: onchange event not working for ui_date field type in UI Page?
the onchange event call this angular function :
$scope.onload = function() {
$scope.updateRecordList(document.getElementById('start_date_row1').value);
};
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2015 08:17 PM
For future reference if you didn't want to create a custom element since using angularjs the same thing you did for your updateRecordList() function could have been done for your date variable:
HTML Markup
<div ng-controller="UpdateRecordController">
<form ng-submit="updateRecordList(date)">
<g:ui_date class="form-control" name="end_date" id="end_date" />
</form>
</div>
In the controller:
app.controller("UpdateRecordController", function($scope){
$scope.date = gel('end_date').value;
$scope.updateRecordList = function(date){
//do some stuff in here with date
}
}
Of course I'm only going by the limited code you supplied so I changed things up a little to test:
HTML Markup
<div ng-controller="UpdateRecordController">
<form>
<g:ui_date class="form-control" name="end_date" id="end_date" />
<br />
<span ng-click="updateRecordList(date)" >Test Button</span>
</form>
</div>
In the controller:
app.controller("UpdateRecordController", function($scope){
$scope.date = gel('end_date').value;
$scope.updateRecordList = function(date){
alert(date)
}
}
Again, I don't know how complex the rest of your code is but this example just shows that you can use AngularJS to grab that data. If the elements aren't in the same controller then using the $rootScope should be possible.