Dev0ps
113
3
Laravel

how to prevent executing parent div class on clicking div child

Posted 3 months ago by Dev0ps
<div class="load" href="/home">
contrnt and tags here...
<div class="load" href="/profile">
profile
</div>
...
...
</div>

if i click on profile than firstly /profile page open than /home page open

code

 if (History.enabled) {
            //if stop changing page on page load
            // if(AjaxInit == 0){AjaxInit=1; return false;}
            var page = get_url_value('page');
            var path = page ? page : 'esn';

            // Load the page
            if(path){
                load_page_content(path);
            }else {return false;}
        } else {
            return false;
        }

  $(document).on('click','.load',function(e){
        e.preventDefault();
        var urlPath = $(this).attr('href');
        var title = $(this).text();
        History.pushState({path: urlPath}, title, '?page=' + urlPath); // When we do this, History.Adapter will also execute its contents.
    });

function load_page_content(page) {
        // alert(page);
        if(PostComposerChecker()){return false;}
        if(page.indexOf('esn') > -1 ){return false;}
        else{
            if (isNavActive == true) {
                NProgress.start();
                isNavActive = false;
                $.ajax({
                    url: page,
                    type: "get",
                    datatype: "html",
                    error: function(xhr, error){isNavActive = true;
                        NProgress.done();
                        Notify("No response from server", "Something went wrong", "error");},
                    success: function (data){
                        console.log(data.status);
                        if(data.status == "CS200"){ $('.cdMain').html(data.html); domreloader();
                            MoveToTop();
                        }
                        // location.hash = page;
                        NProgress.done();
                        isNavActive = true;
                        return false;
                    }
                })
                    .fail(function(jqXHR, ajaxOptions, thrownError)
                    {
                        isNavActive = true;
                        NProgress.done();
                        Notify("No response from server", "Something went wrong", "error");
                        // alert('No response from server');
                    });
            }
        }
    }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.