OOUI/PHP examples/nl

Als u OOUI gebruikt


 * in een MediaWiki-extensie, zie.
 * in een standalone PHP-project, voer  uit.

A more extensive set of most PHP widget examples is available in the source code repository. When you clone the repository and/or install it using composer, take a look at.



De bibliotheek instellen
Before you display any OOUI widgets, you need to set up the library by calling the following functions:

You also need to load the CSS:



Een knop aanmaken
To create a button, use the  class. The first and only argument to a button's constructor is its configuration.

Before the button is converted to HTML and emitted, the label, target and href can be changed using the  and   methods.

The button is now created, and has a label which reads "Still click me!", but is not yet visible to the user, as it must first converted to HTML and echoed into the document:



JavaScript toevoegen
Setting the  property will ensure that clicking the button loads a new PHP page. But if you want to use the technique of progressive enhancement to add client-side JavaScript behaviors to the button, you can "infuse" the object on the client side with the JavaScript OO.ui.infuse method. You must set set the  property when the widget is configured:

Then you'd load some client-side JavaScript to enhance this widget:



Het veilig gebruiken
For extra type safety, you can use the  method of the specific type of widget you expect. That is:

This will throw an exception at runtime if PHP and JavaScript disagree about the widget type of. (As of 2015-05, this is not implemented yet, but will be in the future.)