Skip to content

Ajax Navigation with ajax modals, ajax requests, confirmation messages, ajax form submit and notifications

Notifications You must be signed in to change notification settings

awebdesign/jquery-ajax-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery-ajax-navigation

HTML Attributes

  • data-ajax-nav="modal|modal-save|link"
    default link
    the difference between modal and modal-save is that, modal save has a "Save" button listed in the modal windows which automatically submits the first form which is present in the modal box
  • data-ajax-confirm="Your message here"
    Confirmation modal. If there is no message defined then the default one will be used ("Are you sure?")
  • data-ajax-response="html|json"
    Type of server response. Default is JSON
  • data-ajax-container=".class|#id|this|parent"
    The container can have 'this' as a value, which means will take the current element as container, can have 'parent' which means will take the parent of the actual element or can be an id or class name. By default if the value does not starts with . or #, a # character will be put in front of the value
  • data-ajax-replace=".class|#id|this|parent"
    The container which will be replace with the content received from the server. The container replacement can have 'this' as a value, which means will take the current element as container, can have 'parent' which means will take the parent of the actual element or can be an id or class name. By default if the value does not starts with . or #, a # character will be put in front of the value. When using this attribute, data-ajax-container will be ignored
  • data-ajax-extract=".class|#id"
    If we need to extract only a single element from the whole html content response then we can use this attribute and as a value we can define what element we want to extract. By default if the value does not starts with . or #, a # character will be put in front of the value
  • data-ajax-push="true|false"
    Browser history push. Default false
  • data-ajax-scroll="true|false"
    If the attribute is present then after the request the page will automatically scroll to that element
  • data-ajax-trigger=".class|#id"
    If we need to trigger another ajax-nav element then we can use this attribute and as a value we can define the id or class name of the element we want to trigger. By default if the value does not starts with . or #, a # character will be put in front of the value
  • data-ajax-callback="functionNameHere"
    You can specify your custom callback function/method here and also you can use "this" inside the function/method. By default if there are no params sent you will receive "options" and "response" param

Server Response

The server can repond with HTML or JSON. In order to proccess the output the library needs to know the type of the response which can be done with data-ajax-response="html" else will threat all the responses as JSON.
In case of JSON, here are a few values which can be sent:

  • redirect
    redirects to a specific link
  • alert
    triggers an alert message
  • content
    is the actual content which will be shown
  • success
    will mark the operation as done and will close the modal box
  • notifications
    should be an array or object which can containt the following indexes ['success', 'info', 'warning', 'danger'] and the value can be an array for multiple messages at once or can be a string for a single message per type. The library will trigger and a message for each value found

3rd Party Libraries

About

Ajax Navigation with ajax modals, ajax requests, confirmation messages, ajax form submit and notifications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published