JS - ashish-greycube/help GitHub Wiki

Throw

frappe.throw({
           title: __("Not Available"),
	   message: __('Item Code: {0} is not available under warehouse {1}.', [bold_item_code, bold_warehouse]),
           indicator: 'orange'
	   });

Action On Tab Change

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var target = $(e.target).attr('data-fieldname');
                if (target === 'tab_3_tab') {
                    console.log("ACTIVEEEE")
                } else {
                    console.log("ELSEEEEEEE")
                }
            })

Note: call this 'onload' or 'onload_post_render' event


Importing Function From Another Js File / Include Js File

  1. Create .bundle.js file in public/js folder (e.g. in_words.bundle.js)

  2. In .bundle.js, to add function to frappe object

frappe.my_function = my_function

Include this JS File in Particular Js file,

In js file,

{% include 'path of .bundle.js file'%}

OR

Include this JS file in every js file of app,

In hook.py:

app_include_js = "in_words.bundle.js"

NOTE:

To Call .bundle.js function In another js file

let a = frappe.my_function()