# ui/bindings/preventdefault

module

<a id="functions">

## Functions

<a id="function-preventDefault">

### `preventDefault( view ) → ListenerBinding` _(internal)_

A helper which executes a native `Event.preventDefault()` if the target of an event equals the [element of the view](module_ui_view-View.md#member-element). It shortens the definition of a [template](module_ui_view-View.md#member-template).

```typescript
// In a class extending View.
import { preventDefault } from '@ckeditor/ckeditor5-ui/src/bindings/preventdefault';

// ...

this.setTemplate( {
	tag: 'div',

	on: {
		// Prevent the default mousedown action on this view.
		mousedown: preventDefault( this )
	}
} );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/bindings/preventdefault.ts#L37)

#### Parameters

* `view: View`

  View instance that defines the template.

#### Returns

* `ListenerBinding`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
