2014年4月23日 星期三

rails data-method changed by javascript

reference http://stackoverflow.com/questions/9935956/changing-data-method-with-javascript-does-not-change-what-method-the-ajax-calls

$(this).data('method', 'post'); # sets "data-method" attribute to "post"
$(this).data('method', 'delete'); # sets "data-method" attribute to "delete"
For example, given the following HTML:
<div data-role="page" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>

All of the following jQuery code will work.
$( "div" ).data( "role" ) === "page";
$( "div" ).data( "lastValue" ) === 43;
$( "div" ).data( "hidden" ) === true;
$( "div" ).data( "options" ).name === "John";





沒有留言:

張貼留言