Emily Rodgers wrote:
>
> On Oct 13, 1:20 pm, andreas schmid <[email protected]> wrote:
>   
>> thank you very much for pointing me to the right path!!
>> ill try to understand the behaviour and report about my progress...
>>
>> Andrew Ingram wrote:
>>     
>>> I'm assuming you are doing this somewhere other than the admin, or in
>>> custom views, so I'll explain how the admin stuff works.
>>>       
>>> Basically, when you create the popup window you give it a name which
>>> can be used the uniquely identify the field that is using the popup
>>> (some variant on the field id would be ideal). Your main page (not the
>>> popup) should also have a javascript function to be called after the
>>> new author is saved (in the case of django admin, this function is
>>> called dismissAddAnotherPopup and is in RelatedObjectLookup.js).
>>>       
>>> Now the clever part (which I had to hunt around for when I needed this
>>> functionality, you can find it around line 608 in
>>> django.contrib.admin.options.py), is that when you successfully save
>>> the new author, you return an HttpResponse that consists of nothing
>>> but a script tag that executes
>>> owner.yourFunctionName(window_name,new_object_id (in the case of the
>>> django admin this would be owner.dismissAddAnotherPopup), window_name
>>> is the unique identifier you passed in originally.
>>>       
>>> This causes the browser to execute the function in the owner window
>>> (the one that created the popup) with the parameters you specified -
>>> which includes the ID of the new object. Django's code also provides
>>> the representation string of the object so it can be added to the
>>> select box.
>>>       
>>> Then you just make your JS function close the popup with 
>>> window_name.close().
>>>       
>>> I may not have explained it that well, but the key parts are in
>>> RelatedObjectLookup.js and options.py (near line 608).
>>>       
>>> I hope this helps.
>>>       
>>> - Andrew Ingram
>>>       
>>> 2009/10/13 nabucosound <[email protected]>:
>>>       
>>>> This is the default behaviour in Django Admin, dude...
>>>>         
>>>> On Oct 13, 9:43 am, andreas schmid <[email protected]> wrote:
>>>>         
>>>>> hi,
>>>>>           
>>>>> how can i achieve a behaviour like in the admin backend where i can add
>>>>> a related object through a popup window and have it selectable after i
>>>>> saved the related form?
>>>>>           
>>>>> for example:
>>>>> im copleting the form book and i have to select the author but it doesnt
>>>>> exist yet... so i click on the + (add) button and a popup window appears
>>>>> where i create the editor object, and i can select it in the book form
>>>>> right after i saved and closed this popup window.
>>>>>           
>>>>> can somebody point me to the code?
>>>>>           
>>>>> thank you in advance...
>>>>>           
>
> You might find this helpful: 
> http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/
>
>   
that looks like what i wanted... ill take a look at all your tips asap!
thx

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to