javascript - Mimic Django's "add" button for related fields in admin -
django has admin feature related fields when press "+" button, , can add new data , attaches via jquery, i'm assuming. i've looked @ code, , not find anywhere.
how mimic in php?
so, once add new 'category', id attaches onto 'category' field in window behind it. submit form , wala. how work?
this nice feature of django admin, sonataadminbundle symfony didn't implement (yet). browsed source code , found javascript function:
django/contrib/admin/static/admin/js/admin/relatedobjectlookups.js
function showaddanotherpopup(triggeringlink) { var name = triggeringlink.id.replace(/^add_/, ''); name = id_to_windowname(name); href = triggeringlink.href if (href.indexof('?') == -1) { href += '?_popup=1'; } else { href += '&_popup=1'; } var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); win.focus(); return false; }
maybe can take function , implement own logic in php. when clicking on '+' sign function called this:
<a href="/admin/
app/
model/add/" class="add-another" id="add_id_tags" onclick="return showaddanotherpopup(this);">
the function call made in old fashioned way no use of jquery.
i'm sorry can't further.
Comments
Post a Comment