Giter VIP home page Giter VIP logo

jquery.dirty's Introduction

jquery.dirty

A jQuery plugin to determine when a form has been modified (dirtied) and act accordingly

All state information about the form is held in the data object for the form rather than adding data- attributes to the DOM

Gitter

https://gitter.im/jquerydirty/Lobby

Usage

$("#myForm").dirty();

Options

  • preventLeaving - boolean indicating whether on not to show a warning if the user attempts to navigate away from the form with pending changes

    • Default: false
  • leavingMessage - message to display when preventLeaving is true

    • Default: 'There are unsaved changes on this page which will be discarded if you continue.'
  • onDirty - function called when form is modified

  • onClean - function called when form is restored to original state

Methods

$("#myForm").dirty("isDirty"); returns true if a form has been modified

$("#myForm").dirty("isClean"); returns true if a form has not been modified

$("#myForm").dirty("refreshEvents"); remove and reapply events. Can be used if content is dynamically added to form

$("#myForm").dirty("resetForm"); reset the form to the original state when $("#myForm").dirty(); was called

$("#myForm").dirty("setAsClean"); set the current state of the form as the 'clean' state. Calling resetForm after this will restore the form to the state when setAsCleanwas called

$("#myForm").dirty("setAsDirty"); set the current state of the form as the 'dirty' state

$("#myForm").dirty("showDirtyFields"); returns jQuery array of all modified fields in the form

Credits

Thanks to Tomasz Świenty for feedback and a fix for an issue where a value could resolve as null

jquery.dirty's People

Contributors

simon-reynolds avatar renovate-bot avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar challet avatar davvolun avatar mkllnk avatar wrburgess avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.