You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to implement a classical "if {...} else {...}" object using
JSDecorations.
Then I found there is a JSCondition, but there is no way to describe an "else"
statement.
Also there is an JSIfThenElse decoration, but it is implemented as a ternary
operator (x ? y : z) instead of 'if(x){ y} else {z}'
So I added an extension to JSObject, named #condition:else: and also a
JSConditionElse decoration which produces the expected output.
Can this be added to the main trunk of the Javascript-Core package?
The changes are attached.
With these modifications I was able to transform this Javascript:
$('#ajaxId tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
$('#ajaxId tr.selected').removeClass('selected');
$(this).addClass('selected');
}
} );
Into this:
| selClass |
selClass := 'selected'.
^ (html jQuery: '#' , self ajaxId , ' tbody')
on: 'click'
selector: 'tr'
do:
((html jQuery this removeClass: selClass)
condition: (html jQuery this hasClass: selClass)
else:
(JSScript new
add: ((html jQuery: '#' , self ajaxId , ' tr.' , selClass) removeClass: selClass);
add: (html jQuery this addClass: selClass);
yourself))
Original issue reported on code.google.com by [email protected] on 30 Sep 2014 at 3:06
Original issue reported on code.google.com by
[email protected]
on 30 Sep 2014 at 3:06Attachments:
The text was updated successfully, but these errors were encountered: