1

In one of my projects, I have many different sections where I need to filter some data and select the required, for example - On newsletter page where I need to click a link to "add users" which opens up a popup window where I can search users by name, ID etc then check the checkboxes and click "Select". This adds their IDs (or maybe emails) in the hidden form on the Newsletter page.

Similarly, I need to attach a file to newsletter then I click on an another link which opens up a popup with list of files which I can search and then finally select one. I have similar other requirements in other sections of the website which means I have to write similar type of code again and again.

I won't mind duplicating code if it were to be used at one or two places. But I have more than 8-9 different sections where I have to select users, files, some other items etc so I was thinking if there was a generic plugin sort of tool which takes a url of the search page and returns the data back in a specific format to the parent opener window then I just include that code on each of these pages and just have to maintain one/two files only.

How would you handle this sort of requirement? Is there any JQuery plugin available which does similar thing?

user1421214
  • 909
  • 4
  • 17
  • 24
  • By saying "duplicating code", which part of the code did you mean? dose 8 - 9 different sections may need 8 - 9 different server-side codes. so you just need a simple JavaScript code for opening the pop-up window and load one of the sections in it, then another JavaScript function which by calling it, it fills the hidden input in the parent form and closes the pup-up. is that all you need? – EhsanT Jan 30 '14 at 06:13
  • yes something like that. I have put common code in separate files at the moment so including that on all the sections it kinds of work but was wondering if there's readymade solution already there. – user1421214 Jan 30 '14 at 08:47
  • Unfortunately I'm not aware of such code, but as @Sam Watkins suggested, you can be the one who writes this code. It seems easy to develop, You just need a colorbox(or something like it) to load the sections in the pop-up and then a general JavaScript function which reads the selected items in the pop-up and loads them in the hidden inputs in the parent form regardles of which section is loaded in the pop-up. You just need to standardize the section object names and their data... – EhsanT Jan 30 '14 at 22:56

1 Answers1

0

I'm not aware of a plugin for this, but this Q&A looks relevant:

Open popup and refresh parent page on close popup

Perhaps you can be the hero who implements such a plugin, Mr user1421214!

Community
  • 1
  • 1
Sam Watkins
  • 7,819
  • 3
  • 38
  • 38
  • I have got a somesetup where I have put common code in separate files and then I add section specific code in their own files ... so it's not a plugin but a set of files. :) – user1421214 Jan 30 '14 at 08:49