How can i disable a button once clicked

i need to disable a button after it is clicked once without refreshing a page.

Like 0

Like

2 comments

Add a boolean attribute to the page:

attributes: {
    "IsButtonEnabled": {
		dataValueType: Terrasoft.DataValueType.BOOLEAN,
		type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
		value: true
	}
}

Then bind the enabled property of the button to the attribute:

{
	"operation": "insert",
	"parentName": "Header",
	"propertyName": "items",
	"name": "MyButton",
	"values": {
		"itemType": Terrasoft.ViewItemType.BUTTON,
		"caption": "My button",
		"click": {"bindTo": "onMyButtonClick"},
		"enabled": {"bindTo": "IsButtonEnabled"}
	}
}

Now when it is clicked, set the attribute to false:

onMyButtonClick: function() {
    this.set("IsButtonEnabled", false);
}

Ryan

Ryan Farley,

Hi Ryan, thank u for ur asnwer, is it for Classic or Freedom UI?

 

Show all comments