[CLOSED] How to simulate button click or call Direct Event with Extra Parameter from JS?

  1. #1

    [CLOSED] How to simulate button click or call Direct Event with Extra Parameter from JS?

    Hi All,
    I have a button on my page:
    		<ext:Button ID="SaveChanges" runat="server" Text="Save and Close">
    			<DirectEvents>
    				<Click OnEvent="Save" >
    					<ExtraParams>
    						<ext:Parameter Name="MyParam" Mode="Raw" Value="Ext.encode(#{Store}.getRecordsValues())"></ext:Parameter>
    					</ExtraParams>
    				</Click>
    			</DirectEvents>
    		</ext:Button>
    I need to simulate its Click from JavaScript.
    Is it possible to just simulate it (it would be better), or I have to call Ext.net.DirectEvent.confirmRequest?
    (It works, but I didn't found how to pass extra parameters to this method).
  2. #2
    Hi,

    Please use 'fireEvent' method
    SaveChanges.fireEvent("click");
  3. #3
    Thanks!
    That's exactly what I need.
  4. #4

    A little more complex

    I get a cyclic reference when i try this - got a solution off the top of your head? Basically, I need to implement an asynchronous solution here - you can see i tried firing the directEvent in javascript but that wasn't working, then i looked at your solution and it just keeps prompting to confirm/deny when i do it this way. I know why it's doing it, but i think if i do chk.un("Check") it's not going to solve my problem either....i guess i just need a second pair of eyes.

                                <ext:CheckBox ID="chk1" runat="server" ViewMode="Edit">
                                    <Listeners>
                                        <Check Handler="if(this.checked){confirmOrDeny(this); return false;}" />
                                    </Listeners>
                                    <DirectEvents>
                                        <Check OnEvent="chk1_Checked"/>
                                    </DirectEvents>
                                </ext:CheckBox>
            function fireOverwriteEvent(btn, a, b, chk) {
                if (btn == 'yes') {
    				/*
    				Ext.net.DirectEvent.confirmRequest({
    					control: chk,
    					action: 'Check'	
    				});
    				*/
    				chk.fireEvent('Check');
    			}
            }
            function confirmOrDeny(chk) {
                
                var title =  "Please confirm";
                var message ="Are you sure?";
    
                var btn = Ext.Msg.show({
                    title: title,
                    msg: message,
                    buttons: Ext.Msg.YESNO,
                    fn: this.fireOverwriteEvent.createDelegate(this, [chk], true),
                    animEl: 'elId',
                    icon: Ext.MessageBox.QUESTION
                });
            }
  5. #5
    Hi @ecko,

    I'm afraid I've not got the requirement you are trying to achieve.

    Could you clarify what, but not how you are trying to achieve?

    Also, I think, the initial question of the thread was answered.

    So, please start a new thread.
  6. #6

    figured it out

    Thanks for the reply Danil -

    as usual, as soon as i post my question, i figure out how to fix it.

    I think there's still an issue here, but it doesn't need to be addressed anymore. Less of an issue than a curiosity....

    I got it working by calling the directEvent from javascript directly instead of calling fireEvent.

    I would like to withdraw this so you can focus on other issues....and thanks again!
  7. #7
    Thanks for details!

    I just should remind about DirectMethod - using it in JavaScript might be more consistent.

    Though I don't think you forgot about DirectMethod:)

Similar Threads

  1. Replies: 6
    Last Post: Nov 17, 2011, 9:54 AM
  2. Replies: 1
    Last Post: May 25, 2011, 5:06 PM
  3. Simulate ext:Button click event?
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Dec 16, 2010, 6:16 PM
  4. [CLOSED] Make enter key activate button click direct event
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 15, 2010, 6:02 PM
  5. [CLOSED] [1.0] passing Extra Parameter to button Click from client-side
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 07, 2010, 12:36 PM

Posting Permissions