Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Open YUI Dialog from dynamic button

Expand Messages
  • Daniel
    I have done something similar using server-side scripts: Here, I define the data row click: myDataTable.subscribe( rowMouseoverEvent ,
    Message 1 of 2 , Aug 26, 2009
    • 0 Attachment
      I have done something similar using server-side scripts:
       
      Here, I define the data row click:
       
      myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow);   
      myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);
      myDataTable.subscribe("rowDblclickEvent", myDataTable.onEventSelectRow);
      myDataTable.subscribe("rowSelectEvent", function() {
              var data = this.getRecordSet().getRecord(this.getSelectedRows()[0])._oData;
              var transaction = YAHOO.util.Connect.asyncRequest('GET','getForm.asp?m=Almacenes&pk=' + data.clave_almacen + '&mode=update', getUpdtFormCallback);
       });  
       
      getForm.asp is my script that creates the form and recovers the data.
       
      This is the function to make the dialog appear:
       
      var getUpdtFormCallback = {
              success: function(o) {
       panel = new YAHOO.widget.Dialog('Editing register', {
              fixedcenter: true,
              visible: false,
       modal: true,
       width: '500px',
       constraintoviewport: true,
       buttons: [
                  { text: 'OK', handler: function() {
                      var formObject = document.getElementById('aForm');
                      YAHOO.util.Connect.setForm(formObject);
                      //YAHOO.util.Connect.successEvent.subscribe(updtCallback.success, updtCallback);
                      var Connection = YAHOO.util.Connect;
                      Connection.initHeader("Content-Type","application/x-www-form-urlencoded;  ISO-8859-1");
                      var oResponse = Connection.asyncRequest('POST', 'updateRegister.asp',updtCallback);      
                   } },
                  { text: 'Cancel', handler: function() {
                          panel.hide();}
                   }]
              });
             
       panel.setHeader('Editing register');
       panel.setBody(o.responseText);
       panel.render(document.body);
       panel.show();
       },
              failure: function(o) { alert('Error recovering register');},
              timeout: 3000,
       argument: []
       };

      I know this is not exactly whay you are looking for, but I hope it helps
      2009/8/25 lancemonotone <lancemonotone@...>
       


      I'm trying to open a dialog containing an form to edit the record of a
      particular table row. I'm generating the YUI buttons programmatically as
      follows:

      Code:
      jQuery('.action-cell').each(function(){
      var el_id = $(this).attr('id');
      var edit_cfg = {
      type: "button",
      id: "edit_" + el_id,
      label: "Edit",
      container: $(this).attr('id'),
      onclick: {fn: edit_record}
      };
      new YAHOO.widget.Button(edit_cfg);
      });

      So far, so good. Now, I'd like to use each button to open a YUI dialog
      containing a form to edit the record (which I've already successfully
      rendered so I won't show it here) referred to as 'dlg'. I have a function
      called 'edit_record' that is attached to the onclick event in my
      configuration.

      Code:
      function edit_record(){
      dlg.show;
      }

      However, this is not working at all. Additionally, I'd like to pre-fill the
      form fields in the dialog with the corresponding record by passing it the id
      of the cell ('el_id' in my jQuery .each() function). Can anyone help? If you
      need more info, I'd be glad to provide it.

      Thank you!
      --
      View this message in context: http://www.nabble.com/Open-YUI-Dialog-from-dynamic-button-tp25143115p25143115.html
      Sent from the ydn-javascript mailing list archive at Nabble.com.


    Your message has been successfully submitted and would be delivered to recipients shortly.