Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kaue/jquery-lock

:lock: jQuery Plugin that prevents html changes
https://github.com/kaue/jquery-lock

javascript jquery-lock jquery-plugin lock

Last synced: about 2 months ago
JSON representation

:lock: jQuery Plugin that prevents html changes

Awesome Lists containing this project

README

        

# jQuery Lock Plugin
With this jQuery plugin you will be able to prevent some users from changing content in your page, using the Chrome Developer Tools for example.

[Demo](http://kaue.github.io/jquery-lock/)
## Basic Usage
```html

$( document ).ready(function() {
$("h1,p").lock();
});

I am locked =)


I am locked too!


```

## Options
You can customize the behavior of the plugin using this options:

- `alertMessage` (String)

Send a custom alert for every change on the locked elements

#### Sample
```javascript
$("h1,p").lock({
alertMessage: "You can`t change this."
});
```
- `customHandler(element, updatedHtml, savedHtml)` (Function)

Change the behavior of the plugin, insted of replacing every change with the `savedHtml`.

#### Sample
```javascript
$("h1,p").lock({
customHandler: function(element, updatedHtml, savedHtml) {
//Block the change
$(element).html(savedHtml);
//Do something else with the updatedHtml
console.log('Change blocked %s', updatedHtml);
}
});
```