Override jQuery Event Handlers

Alex Onsman
Updated on 14-Feb-2020 12:33:20

3K+ Views

Use the off() method to override jQuery event handlers. This method is used to remove an event handler. The on() method is used to attach one or more event handler.ExampleYou can try to run the following code to learn how to override jQuery event handlers −Live Demo           jQuery off() method                              $(document).ready(function() {             function aClick() {                $("div").show().fadeOut("slow");             }                             $("#bind").click(function () {                $("#theone").on("click", aClick).text("Can Click!");             });                             $("#unbind").click(function () {                $("#theone").off("click", aClick).text("Does nothing...");             });                          });                              button {              margin:5px;          }          button#theone {              color:red;              background:yellow;          }                             Does nothing...       Bind Click       Unbind Click               Click!                

Implement Custom Events in jQuery

Alex Onsman
Updated on 14-Feb-2020 12:32:17

1K+ Views

Custom event means you can create your own events in jQuery. For example, create a custom event to fire an alert box on pressing any key on the keyboard.ExampleYou can try to run the following code to learn how to create a custom event,Live Demo $(document).ready(function(){    $('textarea').bind("enterKey",function(e){      alert("You have pressed Enter key!");    });    $('textarea').keyup(function(e){      if(e.keyCode == 13)      {         $(this).trigger("enterKey");      }    }); });  

Are jQuery Events Blocking?

Alex Onsman
Updated on 14-Feb-2020 12:28:52

317 Views

Ti check whether jQuery events are blocking, use the .triggerHandler() method, since it returns anything the last event handler for that event on that selector returns.ExampleLive Demo $(document).ready(function(){     var myValue = "John";     $("body").bind("eventName", function(e, value) {        return value + " Jacob";     });    var result = $("body").triggerHandler("eventName", myValue);    alert(result); }); This shows an alert box.

Bind Events on Dynamically Created Elements using jQuery

Alex Onsman
Updated on 14-Feb-2020 12:27:57

4K+ Views

To bind events on dynamically created elements, you need to load dynamically. You can try to run the following code to learn how to bind events on dynamically created elements. Here, we will generate a new list item on button click.ExampleLive Demo $(document).ready(function(){     $("button").click(function(){       $("ul").append("new item ×");       });       $(document).on("click", "a.del" , function() {         $(this).parent().remove();     }); });     Add     Click the above button to dynamically add new list items. You can remove it later.             item    

Debug JavaScript jQuery Event Bindings with Firebug

Alex Onsman
Updated on 14-Feb-2020 11:31:29

290 Views

Let’s say an event handler is attached to your element. For example,$('#foo').click(function() { console.log('clicked!') });Then you can debug it like this:For jQuery 1.3.xvar cEvent = $('#foo').data("events").click; jQuery.each(cEvent, function(key, value) {    console.log(value) }) For jQuery 1.4.xvar cEvent = $('#foo').data("events").click; jQuery.each(cEvent, function(key, handlerObj) {     console.log(handlerObj.handler) }) For jQuery 1.8.x+var cEvents = $._data($('#foo')[0], "events").click; jQuery.each(cEvents, function(key, handlerObj) {   console.log(handlerObj.handler) })

Accessing Table Data from SAP System

Amit Sharma
Updated on 14-Feb-2020 11:28:35

640 Views

Using Select statement you can read data with a dynamic table name. Try using below code &areDATA: lv_tablename TYPE string,    ev_filelength TYPE i. lv_tablename = 'mara'. "e.g. a parameter DATA dref TYPE REF TO data. CREATE DATA dref TYPE TABLE OF (lv_tablename). FIELD-SYMBOLS: TYPE ANY TABLE. ASSIGN dref->* to . SELECT * FROM (lv_tablename) INTO TABLE .

Difference Between event.preventDefault() and return false in jQuery

Amit D
Updated on 14-Feb-2020 11:20:51

670 Views

Returning false from jQuery event handlers is like calling both preventDefault() and stopPropagation(). The preventDefault() method prevents the browser from executing the default action.ExampleYou can try to run the following code to run event.preventDefault() method in jQuery −Live Demo           jQuery preventDefault() method                              $(document).ready(function() {             $("a").click(function(event){                event.preventDefault();                alert( "Default behavior is disabled!" );             ... Read More

Use VBA Macro to Call ABAP Code

Amit Sharma
Updated on 14-Feb-2020 11:18:55

693 Views

Please try using below script −Dim sapConn As Object \Declaring a connection object Set sapConn = CreateObject("SAP.Functions") \Creating an ActiveX object sapConn.Connection.user = "username" sapConn.Connection.Password = "xxxx" sapConn.Connection.client = "client#" sapConn.Connection.ApplicationServer = "Application Server” sapConn.Connection.Language = "PT" If sapConn.Connection.Logon(0, True) True Then //Checking connection here    MsgBox "Not able to login to SAP" Else    MsgBox "Login Successful !!" End If Dim rfcAcctDocCheck As Object Dim oAcctHeader As Object Dim otAcctAR, otAcctGL, otAcctAP, otAcctAMT, otReturn As Object Set rfcAcctDocCheck = sapConn.Add("BAPI_ACC_DOCUMENT_CHECK") Set oAcctHeader = rfcAcctDocCheck.Exports("DOCUMENTHEADER") Set otAcctGL = rfcAcctDocCheck.Tables("ACCOUNTGL") Set otAcctAR = rfcAcctDocCheck.Tables("ACCOUNTRECEIVABLE") Set otAcctAP = ... Read More

Equivalent for Row Number in SAP ABAP

Ali
Ali
Updated on 14-Feb-2020 11:18:18

933 Views

When you want to modify the contents and store them into table and also to add a column for the value, use something likeDATA: my_string TYPE StringLOOP AT itab INTO wa_itab. my_string = sy-tabix. CONCATENATE some_text my_string more_text into wa_itab-my_field. MODIFY itab FROM wa_itab. CLEAR my_string. ENDLOOP.

Compare Data in Two MySQL Tables

Prabhas
Updated on 14-Feb-2020 11:09:29

2K+ Views

Sometimes we need to identify the unmatched data from two tables, especially in the case when data is migrated. It can be done by comparing the tables. Consider the example below in which we have two tables named ‘students’ and ‘student1’.mysql> Select * from students; +--------+--------+----------+ | RollNo | Name   | Subject  | +--------+--------+----------+ |    100 | Gaurav | Computer | |    101 | Raman  | History  | |    102 | Somil  | Computer | +--------+--------+----------+ 3 rows in set (0.00 sec) mysql> select * from student1; +--------+--------+----------+ | RollNo | Name | Subject | ... Read More

Advertisements