Insert relational data in lookup table

edited March 2011 in Modules
Hello,

Here I'm with my second question :) This time I am managing to construct a form that has a look up table, and the look up table has a field that must be inserted at the same time as the relation (Figure 1).

Using a model inside my module I have finished the form to insert the data, I have a control (Figure 2) to select the relation between the two tables, and here is where my question comes. I need to show a pop-up (like the one when you press the "ADD" or "EDIT" button that allow the user to insert the value of the "objetivo" field (Figure 1) at the time you assign "Hitos" to the "indicadores".

What is the best way to do this? Can I attach a JS file to the form from the module to be able to capture the button click and show the pop-up? There are another better way already to achieve that task?

I hope I made my point clear, if not, please tell me and I will try to explain myself better.

Thanks :)

image
Figure 1

image
Figure 2

Comments

  • edited 10:05PM
    You should be able to add your own javascript to the page using the module's "js" or "js_controller" parameters (http://www.getfuelcms.com/user_guide/modules/simple) with the latter being a jQX controller. FUEL uses jQX as a way to structure it's own javascript code but you can use any javascript file you want with the "js" parameter:
    http://www.getfuelcms.com/user_guide/javascript/jqx

    Each simple module inherits from the BaseFuelController that has an "editModule" method that can be accessed from outside the controller by other scripts with page.editModule(url, callback). This method is what is used to create that popup window. The variable 'page' is the name of the jqx global controller variable that gets assigned on a page. Let me know if that makes sense.
  • edited March 2011
    Hi, thanks for your answer :)

    I have been looking into the things you told me, but i was not able to figure out a good way to achieve my aim, may I abuse a bit of your kindness and ask you to give me more detailed insight in how to achieve my aim?

    Thanks a lot :)
  • edited 10:05PM
    Just to clarify, you want a popup window to appear immediately after you make the association between hitos and indicadores and in that popup you want a dropdown of objectvos that they can select and assign with this hito/indicadores association correct?
  • edited 10:05PM
    Yes, that's right, just a thing, ovjetivos is not a dropdown, is a textbox for numeric input. Thanks.
  • edited 10:05PM
    There is not an easy way to do this unfortunately however, it can be done. You will need to add your own js file and subscribe to the 'selectionAdded' event on that multi select form element like so:
    $('#hitos").bind('selectionAdded', function(e, vals){ console.log(vals); //write your own code here to manage the popup and submission of that form })

    I just posted an update to trigger the events 'selectionAdded' and 'selectionRemoved' and so you will need to download the latest fuel/modules/fuel/assets/js/jquery/plugins/jquery.supercomboselect.js. The newly added triggers returns an array of the values being added and removed as the second parameter in your bind function (see above). For what you need though, it may be tricky since you can add more then one at a time with this widget.
  • edited 10:05PM
    Hi, thanks you very much, you are so kind. I think this is going to be enough for my to accomplish my task, thanks for your help and i'll let you know whe finished :)
Sign In or Register to comment.