What does data-ajax=“false” really do?

后端 未结 3 1851
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 16:47

The links on my site don\'t work and I got an solution of using data-ajax=\"false\" on my anchors without getting a true explanation. Can someone help me?

相关标签:
3条回答
  • 2021-01-01 17:15

    if you set the attribute of an element to data-name, you can, through jQuery, fetch it using $('element').data('name') instead of $('element').attr('data-name');, but data-* attributes can still be used for event delegation, like $(document).on('click', '[data-name]', function(){});

    0 讨论(0)
  • 2021-01-01 17:31

    data-ajax is a feature of jQuery Mobile. JQM by default will try to load pages via ajax for improved user experience and transitions. If you set data-ajax='false' then JQM will do a normal page request instead of using ajax. This can be used on forms as well as links.

    From the docs:

    This tells the framework to do a full page reload to clear out the Ajax hash in the URL

    If you want to disable ajax on all of your links then instead of adding data-ajax to everything, you can do it like this:

    $(document).bind("mobileinit", function () {
        $.mobile.ajaxEnabled = false;
    });
    
    0 讨论(0)
  • 2021-01-01 17:41

    Nothing at all.

    data-* is a generic set of attributes that you can store data in for access by JavaScript.

    Unless you have some JavaScript that deals with them, they are meaningless.

    jQuery has nothing built in that does anything with them.

    0 讨论(0)
提交回复
热议问题