So, if there is a need to place a link somewhere in some template, and want it work by post method, i just add a data-method = 'post' attribute.
If i want to send some parameters, then just add data-params-param1 = "param1Value" attribute.
If i need a confirmation before this link work - add data-confirm = "Some comfirmation message" attribute.
The question is: what other data-* attributes i can use when developing with Yii2, or where i can find information.
I have tried to google, look in Yii2 api - no results.
AFAIK there is no documentation for this at the moment. It's only mentioned in few places.
Based on the current yii.js, yii,captcha.js, and yii.gridView.js these data-* are specially handled:
form
method
params
pjax
pjax-push-state
pjax-replace-state
pjax-timeout
pjax-scrollto
pjax-push-redirect
pjax-replace-redirect
pjax-skip-outer-containers
pjax-container
yiiActiveForm
yiiSubmitFinalizePromise
yiiCaptcha
key
Related
I'm using attempting to add an "onclick" object to a page in a singlesite (i.e. rather than multisite) WordPress that triggers an event. The code is:
Send a voice message
When attempting to save the code, WordPress strips the onclick object leaving:
Send a voice message
A user on another forum suggested that this restriction should only apply to multisite non-superadmin users. Again, this is a siglesite with only one admin user.
It is understood that WordPress removes "onclick" from HTML to prevent malicious code. Still, does anyone know how to resolve this?
Thanks.
It appears that with current Wordpress (I'm on 4.9.4), TinyMCE does the filtering directly on the editor screen, not when the form is submitted. The allowedtags and allowedposttags don't seem to matter, so the solution above does not solve the problem for me.
The method I have developed uses the tiny_mce_before_init filter to alter the allowed tags within TinyMCE. The trick is to add the extended_valid_elements setting with the updated versions of the elements allowed for a.
First, look in the page http://archive.tinymce.com/wiki.php/Configuration3x:valid_elements to find the current value for a, which right now is
a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]
And add to the end of that the onclick attribute:
a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick]
Then use that in the filter function like this:
function allow_button_onclick_mce($settings) {
$settings['extended_valid_elements'] = "a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick]";
return $settings;
}
add_filter('tiny_mce_before_init', 'allow_button_onclick_mce');
which you install in your functions.php file in Wordpress. You can see it in action by toggling the text and visual view on the edit page. Without the extended list, the onclick goes away. With it, it remains.
You can solve this by changing the anchor tag into button and adding a script. For more info please refer to this link: Wordpress TinyMCE Strips OnClick & OnChange (need jQuery).
By resolving, I'm assuming you mean to allow the onclick attribute. You will want to be careful with this, because modifying the allowed tags does this for all your users.
You can modify the list of allowed tags and attributes, by adding this to your functions.php file:
function allow_onclick_content() {
global $allowedposttags, $allowedtags;
$newattribute = "onclick";
$allowedposttags["a"][$newattribute] = true;
$allowedtags["a"][$newattribute] = true; //unnecessary?
}
add_action( 'init', 'allow_onclick_content' );
I suggest trying it with only $allowedposttags first to see if that works for you. According to this other stackexchange post, you should only need allowedtags if you need it for comments or possibly non-logged-in users, but when I did something similar in the past, I needed both of them to work.
On a side note, if you want a list of all already allowed tags and attributes, look inside your /wp-includes/kses.php file.
I am learning ASP.NET MVC and came across this particular Html Helper method.
When would one use
#Html.RouteLink("Routed Link", new { controller = "Home", action = "About", id="MyID"})
What is the difference between this and Html.ActionLink()?
ActionLink is a specific way to link to a specific action by specifying the action and controller. RouteLink gives you more control over the routing. For instance, look at this override which gives you the most flexibility in generating a URL, not necessarily tied to an action.
According to: What's the difference between RouteLink and ActionLink in ASP.NET MVC?
ActionLink will generate the URL to get to an action using the first
matching route by action name.
RouteLink will generate a URL to a specific route determined either by
name or route values.
I'm testing struts2 jquery-grid-tree plugin but when I render a tree whose info come from an action in JSON format, I have some troubles.
As I want more info from my action for another purposes, my action return not only tree nodes info, but other regarding as operation ACK, and so on...
That's an example of my action result:
{"JSON":"success", "nodes":[{id":"001", "children":null,"data":{"title":"First element "}, "icon" : null,....
So in my tree tag I try to tell the plugin to retrieve info from "nodes" property inside the action's response using "rootNode" property, in this way:
<sjt:tree
href="%{testJSONTreeAction}"
id="testTreeWithCheckbox"
rootNode="nodes"
childCollectionProperty="children"
....
but it doesn't work.
The only way it runs fine is if my response returns just the info about my tree as follows:
[{"attr":{"id":"001"},"children":null,"data":{"title":"First element"}...
I means, just the node information.
Of course I could manage formatting the response as above, but I wonder what is this attribute for. Other tags like grid tags has an attribute for this (gridModel) and works fine, but I can't find it in tree tags docs.
I've seen some related bugs like here but they are regarding old versions and I'm trying the last release of the plugin, 3.5.1.
Thanks in advance,
I want to share a specific part of a page so I use a hashlink for example: http://en.wikipedia.org/wiki/List_of_GMA_Network_radio_stations#References
Facebook parses the <p> tag closest to the element with the linked id.
Is there a way to tell Facebook what it should use as description? Ideally I'd like to do this on an individual basis.
UPDATE: Since #Sturmeh suggests that I can post the link description via the API I'm enclosing the code that isn't working:
$statusUpdate = array(
'link' => $share_link,
'message' => $message,
'description' => $description
);
//Post to Facebook
$facebook->api("/$user_id/feed", "post", $statusUpdate);
No, it cannot be done via a "share" functionality or default "like" button, and here's the problem: You, from the server-side, cannot access the hashlink. If you could, you could manipulate the the description meta tag to reflect the hashlink. But, as i said, you cannot access the hash from the URL. So, your only option (if you want a "like" button on your site) is to implement a custom like button that will call the Graph API.
But from my understanding, you want a different description when a user "shares" that url on Facebook. Unfortunately, given the current restraints on server-side languages accessing that hashlink, it's not possible.
https://developers.facebook.com/docs/reference/api/link/
description: A description of the link (appears beneath the link caption)
The REST API does not support the description field, you should be posting to the feed connection of a user. (Using the Graph API)
To clarify:
According to this page, you should; use the Graph API and POST a Post object to the feed connection of the User object.
A form in my app has the following:
<form action="/faculty/update/agxzdGFuZHJld3NqaHNyDQsSB0ZhY3VsdHkYBww" method="PUT" accept-charset="utf-8">
However, upon submission the request is treated as a GET and is handled by def get() and not def put(). Any help would be appreciated!
Edit:
Thanks for the responses. If I can't use method="PUT" what is the best way of directed the form the the put() method within my handler class? Should I add another handler within main.py?
HTML v4 and XHTML v1 only support the GET and POST request methods within HTML forms.
On the other hand the GET, POST, PUT and DELETE methods are supported via XMLHttpRequest in all modern browsers.
Related Stack Overflow post:
Are the PUT, DELETE, HEAD, etc methods available in most web browsers?
EDIT:
Further to your update, I think your only options would be:
Use the POST method in your form and handle it through the post() handler.
Use AJAX (XMLHttpRequest) to post your form with JavaScript, using the PUT method.
Use HTML5, but this will not work in Internet Explorer.
Browsers only do GET & POST methods. See if your app's platform can simulate PUT methods via a "method" parameter.
I believe GET and POST are the only valid values on a FORM method attribute.