﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6284	[newforms-admin] text.replace is not a function	trbs	nobody	"Saving a new record in the popup of a foreignkey in newform-admin yields a ""text.replace is not a function"" for me.

This is because in dismissAddAnotherPopup() function in RelatedObjectsLookups.js the newId parameter get html_unescape'd.

But it looks like it correctly gives a Int to the function and not a string hence the replace function fails.

Solution looks as simple as removing the html_unescape function from the function.

{{{
Index: RelatedObjectLookups.js
===================================================================
--- RelatedObjectLookups.js	(revision 6979)
+++ RelatedObjectLookups.js	(working copy)
@@ -54,7 +54,6 @@
 function dismissAddAnotherPopup(win, newId, newRepr) {
     // newId and newRepr are expected to have previously been escaped by
     // django.utils.html.escape.
-    newId = html_unescape(newId);
     newRepr = html_unescape(newRepr);
     var name = win.name.replace(/___/g, '.');
     var elem = document.getElementById(name);
}}}

But i might be forgetting some other usecase here where a string is passed to the function as 'newId' if so one could use something like:

{{{
Index: RelatedObjectLookups.js
===================================================================
--- RelatedObjectLookups.js	(revision 6979)
+++ RelatedObjectLookups.js	(working copy)
@@ -54,7 +54,9 @@
 function dismissAddAnotherPopup(win, newId, newRepr) {
     // newId and newRepr are expected to have previously been escaped by
     // django.utils.html.escape.
-    newId = html_unescape(newId);
+    if (typeof(newIf)!=""numer"")) {
+	newId = html_unescape(newId);
+    }
     newRepr = html_unescape(newRepr);
     var name = win.name.replace(/___/g, '.');
     var elem = document.getElementById(name);
}}}"		closed	contrib.admin	newforms-admin		duplicate			Unreviewed	1	0	0	0	0	0
