asiaH5/modules/e_paper/_subscriber_widget.html.erb

39 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-19 03:11:35 +00:00
<div class="epaper-form" id="form_{{subpart-id}}">
<form action="" class="form-horizontal">
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="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},
dataType : "json",
type : "get"
}).done(function(data){
alert(data.msg);
$("#form_{{subpart-id}} form")[0].reset();
})
}
return false;
})
</script>