Stimulus 및 StimulusReflex에서 Rails UJS 확인 사용
2941 단어 rubystimulusrailsjavascript
상호 작용에 확인 단계를 추가해야 하는 경우(사용자가 개체를 파괴하려고 시도하는 경우 일반적인 패턴임)you can make use of the
data-confirm
attribute:<button data-confirm="Are you sure you want to remove this context?">
<%= render_svg 'icons/custom/remove' %>
</button>
Stimulus 또는 StimulusReflex와 함께
data-confirm
를 사용하려고 하면 data-confirm
is not supported out-of-the-box을 알 수 있습니다. data-action
또는 data-reflex
와 함께 사용하려면 사용자가 확인 모달을 수락할 때 confirm:complete
에 의해 트리거되는 click
대신 rails-ujs
이벤트를 수신하기만 하면 됩니다.<button data-reflex-dataset="combined"
data-confirm="Are you sure you want to remove this context?"
data-reflex="confirm:complete->Context#remove_context">
<%= render_svg 'icons/custom/remove' %>
</button>
이제
data-action
또는 data-reflex
로 지정된 작업은 사용자가 확인 대화 상자를 수락하는 경우에만 트리거됩니다. 이를 통해 Stimulus 또는 StimulusReflex 상호 작용에 확인 단계를 쉽게 추가할 수 있습니다.대화 디자인 플랫폼Voxable을 구축하는 동안 이 문제를 만났습니다. 챗봇이나 음성 응용 프로그램을 만들고 있다면 check it out !
Reference
이 문제에 관하여(Stimulus 및 StimulusReflex에서 Rails UJS 확인 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/techpeace/using-rails-ujs-confirmations-in-stimulus-and-stimulusreflex-4f6e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)