AsiaV1/modules/e_paper/_subscriber.html.erb

39 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-19 03:12:03 +00:00
<div class="epaper-form" id="form_{{subpart-id}}" style="margin-top:20px;">
<form action="" class="form-horizontal">
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="submit" data-type="subscribe" class="btn btn-primary" value="Subscribe">
<input type="submit" data-type="unsubscribe" class="btn btn-danger" value="Unsubscribe">
</div>
</div>
</form>
</div>
<script type="text/javascript">
$("#form_{{subpart-id}} form input[type=submit]").on("click",function(){
var el = $(this),
val = $("#form_{{subpart-id}} input[name=email]").val(),
url = null;
if(el.data("type") == "subscribe"){
url = "/xhr/epaper/subscribeuser";
}else if(el.data("type") == "unsubscribe"){
url = "/xhr/epaper/unsubscribeuser"
}
if(val != ""){
$.ajax({
url : url,
data : {"email" : val, "language" : I18n.locale},
dataType : "json",
type : "get"
}).done(function(data){
alert(data.msg);
$("#form_{{subpart-id}} form")[0].reset();
})
}
return false;
})
</script>