misleading example on access of widget instance through .data()

オープン
#796 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, jquery
領域
documentation

調査の方向性

リンク先の jQuery Learning Center のページを開き、「The Widget Factory Under the Hood」セクション、特に .progressbar() と .data("nmk-progressbar") の例を確認してください。jQuery UI progressbar インスタンスと nmk-progressbar プラグインを正確に区別できるよう、例またはその説明を更新し、その後、レンダリングされたドキュメントが明確であることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Chapter: plugins

https://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/#the-widget-factory-under-the-hood

When a plugin instance is created, it is stored on the original DOM element using jQuery.data, with the plugin's full name (the plugin's namespace, plus a hyphen, plus the plugin's name) as the key.

var bar = $( "<div />")
    .appendTo( "body" )
    .progressbar()
    .data( "nmk-progressbar" );
 
// Call a method directly on the plugin instance.
bar.option( "value", 50 );
 
// Access properties on the plugin instance.
alert( bar.options.value );

I think the example given is misleading even with the namespace specified in accessing jQuery.data,
i.e. .data("nmk-progressbar").

The issue is that .progressbar() actually creates an instance of the Progressbar Widget of jQuery UI https://api.jqueryui.com/progressbar/#quick-nav rather than one of the plugin nmk-progressbar
built with Widget Factory.

The code snippet happens to make it being able to access the plugin instance of nmk-progressbar
by using the key "nmk-progressbar", which does run successfully but incorrect in meaning.

As considering the context in the article is with jQuery UI Widget Factory, this suggests audiences
that it is a way, using .progressbar(), to make an instance of the plugin nmk-progressbar.

I hope I am not wrong and expect for comments from anyone experienced.
Thanks ^_^

主要言語
JavaScript
スター
914
フォーク
472
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jquery/learn.jquery.com のほかの issue

jquery/learn.jquery.com の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。