Class JQueryBehavior

    • Field Detail

      • selector

        protected String selector
      • method

        protected final String method
      • options

        protected final Options options
    • Constructor Detail

      • JQueryBehavior

        public JQueryBehavior​(String selector)
        Constructor
        Parameters:
        selector - the html selector (ie: "#myId")
      • JQueryBehavior

        public JQueryBehavior​(String selector,
                              String method)
        Constructor
        Parameters:
        selector - the html selector (ie: "#myId")
        method - the jquery method
      • JQueryBehavior

        public JQueryBehavior​(String selector,
                              String method,
                              Options options)
        Constructor
        Parameters:
        selector - the html selector (ie: "#myId")
        method - the jquery method
        options - the Options
    • Method Detail

      • detach

        public void detach​(IPartialPageRequestHandler handler)
        Removes the element matching the current selector from the DOM.
        The #detach method is the same as #remove, except that #detach keeps all jQuery data associated with the removed elements.
        This method is useful when removed elements are to be reinserted into the DOM at a later time.
        Parameters:
        handler - the IPartialPageRequestHandler
        See Also:
        remove(IPartialPageRequestHandler)
      • remove

        public void remove​(IPartialPageRequestHandler handler)
        Removes the element matching the current selector from the DOM.
        Use #remove when you want to remove the element itself, as well as everything inside it.
        In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.
        To remove the elements without removing data and events, use #detach instead.
        Parameters:
        handler - the IPartialPageRequestHandler
        See Also:
        detach(IPartialPageRequestHandler)
      • getSelector

        public String getSelector()
        Gets the selector
        Returns:
        the selector
      • setSelector

        protected void setSelector​(String selector)
        Sets the selector
        Parameters:
        selector - the html selector (ie: "#myId")
      • getMethod

        public String getMethod()
        Gets the jQuery method
        Returns:
        the method
      • getOption

        public <T> T getOption​(String key)
        Gets a behavior option, referenced by its key
        Type Parameters:
        T - the object type
        Parameters:
        key - the option key
        Returns:
        null if the key does not exists
      • setOption

        public JQueryBehavior setOption​(String key,
                                        Object... values)
        Sets a behavior option, with multiple values.
        Parameters:
        key - the option key
        values - the option values
        Returns:
        the JQueryBehavior (this)
      • setOption

        public JQueryBehavior setOption​(String key,
                                        List<?> values)
        Sets a behavior option, with multiple values.
        Parameters:
        key - the option key
        values - the option values
        Returns:
        the JQueryBehavior (this)
      • setOptions

        public void setOptions​(Options options)
        Adds or replace behavior options
        Parameters:
        options - the Options
      • on

        protected void on​(String event,
                          String callback)
        Registers a jQuery event callback
        Parameters:
        event - the jQuery event (ie: "click")
        callback - the jQuery callback
      • on

        protected void on​(String selector,
                          String event,
                          String callback)
        Registers a jQuery event callback
        Parameters:
        selector - the html selector (ie: "#myId")
        event - the jQuery event (ie: "click")
        callback - the jQuery callback
      • off

        protected void off​(String selector,
                           String event)
        Unregisters a jQuery event callback
        Parameters:
        selector - the html selector (ie: "#myId")
        event - the jQuery event (ie: "click")
      • register

        protected void register​(String statement)
        Registers a jQuery event statement
        Parameters:
        statement - the jQuery statement (ie: "jQuery('#myId').on('click', function() {});")
      • $

        public String $​(String options)
        Gets the jQuery statement.
        Warning: This method is *not* called by the behavior directly (only $() is).
        Parameters:
        options - the options to be supplied to the current method
        Returns:
        the jQuery statement
      • $

        public String $​(Options options)
        Gets the jQuery statement.
        Warning: This method is *not* called by the behavior directly (only $() is).
        Parameters:
        options - the Options to be supplied to the current method
        Returns:
        the jQuery statement
      • $

        public String $​(Object... options)
        Gets the jQuery statement.
        Warning: This method is *not* called by the behavior directly (only $() is).
        Parameters:
        options - the list of options to be supplied to the current method
        Returns:
        the jQuery statement