Re: how to create (open) a dialog box [message #175136 is a reply to message #175134] |
Tue, 16 August 2011 20:02 |
sheldonlg
Messages: 166 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 8/16/2011 1:03 PM, Thomas 'PointedEars' Lahn wrote:
> Robert Hairgrove wrote:
>
>> On 08/16/2011 02:50 AM, sheldonlg wrote:
>>> On 8/15/2011 2:18 PM, A.Reader wrote:
>>>> Andre, one way to avoid having to ask whether the person wants to
>>>> delete the record is to make deleting it a 2- or 3-action
>>>> process.
>>>>
>>>> For example, you might require that they check 2 checkboxes and
>>>> click a button. A person might accidently check one box and
>>>> click the button, but it's quite unlikely that they'll check
>>>> _both_ boxes for the same record by mistake.
>>>
>>> ....or simply use an onClick to have a confirm message box pop up.
>
> For the reasons detailed below, `onClick' (or `onclick' in XHTML) is the
> wrong event-handler attribute (and `click' is the wrong event) to use here.
>
>> Exactly! And this is done in web applications using a client scripting
>> language (such as JavaScript, not PHP).
>
> You are still wrong about which language can be used where, and you really
> do not know what JavaScript is.
>
> However, more important to notice is that the drawback of a client-side only
> solution in the client-server model – assuming this is the case here – is
> that – rather obviously – it does not work without client-side support.
> There is the NoScript extension, for example, to prevent client-side scripts
> from running, as many people have used client-side scripting for rather
> dubious purposes.
>
> The client-side dialog – in fact, any client-side code – should augment a
> server-side generated solution (to reduce the number of roundtrips to the
> server, thus enhancing user experience and reducing server/network load);
> with few exceptions, it should not replace it. This can be done easily, for
> example:
>
> <form action="delete-dialog.php"
> onsubmit="return window.confirm('Delete?')">
> <input type="submit" value="Delete">
> </form>
>
> The best solution regarding this approach is a server-side framework which
> provides the classes to generate the forms (here: both for submitting the
> deletion request and confirming it) and the client-side code, so that the
> data only needs to be maintained in one place.
>
>
> PointedEars
Wouldn't you use onsubmit only if you are submitting the entire page?
The onclick allows you to confirm the deletion, send off an AJAX
request, and still stay on the page.
--
Shelly
|
|
|