How to invoke click of a button clientside?

  1. #1

    How to invoke click of a button clientside?

    How can I programmatically invoke the click event of a ext button on the clientside so it will fire off the AjaxEvent? So far, I have been doing:

    btnSave.getEl().dom.click()
    Is there a better way? What about other events that are specific to the ExtJS component?
  2. #2

    RE: How to invoke click of a button clientside?



    Hi jchau,

    With v0.7 we've made several refinements to the AjaxEvent functionality and API.

    With the next release you'll have a couple options to manually fire an AjaxEvent whos event handler has been configured in the code-behind.

    The first option is to manually call the .fn function which contains the AjaxEvent configuration as rendered on Page_Load. This method ensures the exact same AjaxEvent configuration object is always passed to the new .request() function. Calling .fn basically mimics a manual firing of the event.

    Example


    // Call the .fn function which contains the AjaxEvent configuration
    Button1.ajaxEvents.click.fn()
    A second option is to build the request configuration object manually, then pass into the .request function.

    Example

    Coolite.Ext.AjaxEvent.request({control: Button1});
    We're still testing and tuning this new AjaxEvent functionality, but the current code is availabe in SVN and will included with the public release of v0.7.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3

    RE: How to invoke click of a button clientside?

    That's great news! Does an AjaxEvent HAVE to be associated with a html control?
  4. #4

    RE: How to invoke click of a button clientside?

    Button1.ajaxEvents.click.fn()

    Code above no longer works. *I get an exception.


    Object reference not set to an instance of an object.
    Source Error: 
    
    
    <table width="100%" bgcolor="#ffffcc">
    <tbody>
    <tr>
    <td><code>Line 1662:
    Line 1663:            PropertyInfo eventListenerInfo = listeners.GetType().GetProperty(eventName);
    Line 1664:            if (eventListenerInfo.PropertyType != typeof(ComponentAjaxEvent))
    Line 1665:            {
    Line 1666:                throw new HttpException(string.Format("The ScriptManager has no listener with name '{0}'", eventName));</code></td></tr></tbody></table>
    Source 
    File: C:\Program 
    Files\Coolite\SVN\toolkit\Coolite.Ext.Web\Core\ScriptManager.cs ** Line: 
    1664
  5. #5

    RE: How to invoke click of a button clientside?

    Hi jchau,

    Please use this
    Button1.ajaxEvents.click.fn.apply(Button1)*


    Or
    Button1.ajaxEvents.click.fn.apply(Button1, [])*





  6. #6

    RE: How to invoke click of a button clientside?

    Can you elaborate more on the second parameter? What does it mean to pass []? Will this still send back all the parameters defined back to the server?
  7. #7

    RE: How to invoke click of a button clientside?

    apply is function which calls the function with setted scope (first argument)*Second argument is array of arguments which will be passed to the called function


Similar Threads

  1. [CLOSED] When button click, open the menu of button
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:23 PM
  2. Replies: 3
    Last Post: Jan 31, 2012, 1:28 PM
  3. Replies: 4
    Last Post: Nov 19, 2010, 1:39 PM
  4. Replies: 2
    Last Post: Oct 30, 2009, 1:54 PM
  5. Replies: 3
    Last Post: Mar 26, 2009, 1:25 PM

Posting Permissions