<AdminEdit>
This feature request would be used to monitor the requests for a full-fledged Dialog component. It will be defined in the Markup and will provide options to customize the Header and Content and will expose Action buttons.
</AdminEdit>
I want to fill the textbox of the prompt with predefined text, can we have that same behavior like in kendo https://docs.telerik.com/kendo-ui/api/javascript/kendo/methods/prompt?
---------
ADMIN EDIT
Here is a workaround
@inject IJSRuntime _js
<TelerikButton OnClick="@PromptWithText">Workaround</TelerikButton>
@code{
[CascadingParameter]
public DialogFactory Dialogs { get; set; }
async Task PromptWithText()
{
// the workaround - invoke a script that will set the input value with a delay
await _js.InvokeVoidAsync("setPromptDefaultText", "predefined prompt value");
// do the prompts as usual
string prompt = await Dialogs.PromptAsync("Enter something");
Console.WriteLine(prompt);
}
}
@* move this script to a proper location, this is a hack
to put in the blazor component so the workaround is easy to copy and run *@
<script suppress-error="BL9992">
function setPromptDefaultText(defText) {
setTimeout(function(){
var promptInput = document.querySelector(".k-prompt-container .k-textbox .k-input-inner");
if(promptInput) {
promptInput.value = defText;
promptInput.dispatchEvent(new Event('input', {bubbles: true} ));
}
}, 50); // a timeout so the prompt can render first
}
</script>
---------
Hello,
Please add support for MarkupString in the predefined awaitable dialogs. This will allow us to add new lines and other simple rich content, without the need to resort to the full-blown Dialog component.
Currently using VisibleChanged event, I can tell when a dialog is closed. However, if you have a component inside the dialog and trying to reference that component before the dialog is fully rendered you get a null reference exception.
What I am proposing is adding a new event or extending VisibleChanged so that we know when the dialog has been initialized.
Can I define the Cancel home button by default? When deleting a line I use Confirm Dialogs, I want the default (active) button to be Cancel (not Ok)
---
ADMIN EDIT
Here is a solution you can use:
@inject IJSRuntime _js
@* move this script to a proper place in your project and remove the
suppress-error hack that lets it stay in the component - it is here for brevity only *@
<script suppress-error="BL9992">
function focusCancelDialogButton() {
setTimeout(function() {
var cancelButtons = document.querySelectorAll(".k-dialog .k-dialog-buttongroup .k-button");
if(cancelButtons && cancelButtons.length > 1) {
cancelButtons[1].focus();
}
}, 100);
}
</script>
<TelerikButton OnClick="@ShowConfirm">Show Confirm</TelerikButton>
@code {
[CascadingParameter]
public DialogFactory Dialogs { get; set; }
public async Task ShowConfirm()
{
await _js.InvokeVoidAsync("focusCancelDialogButton");
bool isConfirmed = await Dialogs.ConfirmAsync("Are you sure?");
if (isConfirmed)
{
Console.WriteLine("The user is sure, continue.");
}
else
{
Console.WriteLine("The user changed their mind");
}
}
}
---