mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Fix rendering during search
This commit is contained in:
		| @@ -729,6 +729,10 @@ function initializeRelatedField(name, field, options) { | ||||
|                 data = item.element.instance; | ||||
|             } | ||||
|  | ||||
|             if (!data.pk) { | ||||
|                 return $(searching()); | ||||
|             } | ||||
|  | ||||
|             // Custom formatting for the search results | ||||
|             if (field.model) { | ||||
|                 // If the 'model' is specified, hand it off to the custom model render | ||||
| @@ -750,6 +754,10 @@ function initializeRelatedField(name, field, options) { | ||||
|                 data = item.element.instance; | ||||
|             } | ||||
|  | ||||
|             if (!data.pk) { | ||||
|                 return $(searching()); | ||||
|             } | ||||
|  | ||||
|             // Custom formatting for selected item | ||||
|             if (field.model) { | ||||
|                 // If the 'model' is specified, hand it off to the custom model render | ||||
| @@ -794,6 +802,11 @@ function initializeRelatedField(name, field, options) { | ||||
| } | ||||
|  | ||||
|  | ||||
| // Render a 'no results' element | ||||
| function searching() { | ||||
|     return `<span>{% trans "Searching" %}...</span>`; | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Render a "foreign key" model reference in a select2 instance. | ||||
|  * Allows custom rendering with access to the entire serialized object. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user