Ratchet remove/add data-ignore="push"

450 Views Asked by At

Using ratchet framework, I am able to slidein/slideout of any pages, I arrive on a situation where I have to get the data first before it slides to the next page. I can get the data but the slide transition of the page is gone. Is there a way to do this?

I have this example anchor here:

<a href="next-link.html" data-transition="slide-in" data-want="I want this data here">Next link</a>

tried using,

$('a').each(function() {

`var $this = $(this);`

`$this.attr('data-ignore', 'push');`

`$this.click(function(e) {`

    `e.stopPropagation();`

    `//... get the data here $this.attr('data-want')`

    `$this.attr('data-ignore', '');`

`});`

});

2

There are 2 best solutions below

2
On

use .data() instead:

$this.data('ignore', 'push');

and to set it empty

$this.data('ignore', '');
0
On

This is what I use, the advantage of "on" is that it will work whenever an a tag is appended to the page. You can remove the if statement if you want to, I'm using PhoneGap so this gets around some issues for me.

        $(document.body).on('click', 'a', function(e){
            $(this).attr('data-ignore', 'push');    //disables ratchet push.js for now!
            var url = $(this).attr('href');
            if (url && url.indexOf('http') == -1) {
                location.href = url;
            }
        });