How to override the java script default editable bootstrap values in Django

13 views
Skip to first unread message

Srinivas Gadi

unread,
Sep 16, 2018, 6:39:39 AM9/16/18
to Django users

I am stuck at overriding the default editable bootstrap values in Django framework javascript html page

In my webpage, it coded as below

$.fn.editable.defaults.url = "{% url 'page1' model.PATH %}";

Now my requirement is, When I click on a button, it check the views.py(page1, which is default URL) and pass the context through 'return HttpResponse' to html page that "True" or "False" based the value, if false, it should go page2, it never goes to page2 url, its entered to the function conflict_warn() but not inside and eventually it failed with the,Uncaught TypeError:e.getAttribute is not a function I tried number of ways, but all are vain.

$(this).editable({
    value: "",
    display: false,
    success: function (response, newValue) {
        if (response.hasOwnProperty("State"))){
    conflict_warn(response, newValue)//if State value True,should go to other func
}
    else {
    window.location.href = "{% url 'path1' 'path2'%}" + response;
}
        },
error: function(response, newValue) { $(this).editable("destroy"); }
    });
$(this).editable("submit");


function conflict_warn(response, newValue) {
    $(this).editable({
        value: ""
    display: false
    success: function (response.newvalue) {
            window.location.href = "{% url 'path1' 'path2'%}" + response;
        }
    });
    $(this).editable("setValue", "{% url 'page1' model.PATH %}");
    $(this).editable("submit");
}
Reply all
Reply to author
Forward
0 new messages